进出口使用AJAX使用AJAX:无效JSON响应
http:xxx.myserver.com/myfolder/example.json
$.ajax({
url:"http:xxx.myserver.com/myfolder/example.json",
dataType:"json",
success:function(data, status) {
alert("success"+data+":::"+status);
},
error:function(request, status, error) {
alert("Error:"+JSON.stringify(request)+":::"+status+"::"+error);
},
});
为此,我得到的输出像下面
Error:{"readyState":0,"responseText":"","status":0,"statusText":"error"}:::error::
我用Google搜索的解决方案也有人说,来替代阅读我的JSON数据JSON来JSONP如果我更换
dataType:json to dataType:jsonp
我喜欢输出
Error{"readyState":4,"status":200,"statusText":"success"}:::parsererror::Error: jQuery110107852220840286463_1387290139272 was not called
它不是在所有进入成功功能。
请任何人都为我提供解决方案。提前致谢。
使用浏览器开发者控制台直接检查服务器响应。 – Pointy
请使用描述性问题标题。 – undefined
如果Web服务支持它,则只能使用JSONP,如果脚本托管在另一个域上,而不是ajax url,则只需要它。 (如果它们不同,请参阅http://en.wikipedia.org/wiki/Same-origin_policy) – xec