$.ajax({
   url:"http://***.***.***.***:8000/worker_json",
   dataType:"json",
   error : function(XHR, status, error) {
            alert("There was an error processing the request.\n\n"+XHR.responseText+status);
        },
        success : function(json){
            if (!json.length) {
                alert('There are no incorrectly spelled words...'+json[0]+ '  ' + json.length);
            } else {
                // highlight bad words
$("#myDiv").append(json);
            }
           // cl.$container.html(html);   
            // execute callback function, if any
           // (callback != undefined) && callback(); 
        }
});

解决方案 »

  1.   

    请问是后台解析ajax请求的问题吗?
      

  2.   

    浏览器总是返回:“There was an error processing the request.  error” 什么提示都没有
      

  3.   

    1可能是被调用的方法问题,导致返回的值有错误
    2.可能你的struts配置有问题
    <package name="web.defaultjson" extends="json-default" namespace="/web">         
            <action name="webdefaultjson_*" class="action.web.DefaultAction" method="{1}">
                <result name="success"  type="json" ></result>
            </action>      
        </package> 
      

  4.   

    没有使用struts 只是简单的html请求
    然后使用ajax请求本地文件也不行$.ajax({
       url:"./data.json",
       dataType:"json",
       error : function(XHR, status, error) {
                alert("There was an error processing the request.\n\n"+XHR.responseText+" status:"+status+" url:"+error.url);
            },
            success : function(json){
    var data = eval("("+json+")");
     
    $("#myDiv").innerHTML = data;
          
            }
    });
      

  5.   

    url:"http://***.***.***.***:8000/worker_json"这返回的内容是什么?不要输出怪异的json格式的字符串,要不jq1.4+版本不会执行success回调。如{abc:1}或者{'abc':1},要输出{"abc":1}具体参考
    jQuery dataType指定为json的问题