$.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();
}
});
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();
}
});
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>
然后使用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;
}
});
jQuery dataType指定为json的问题