如何使用jquery ajax接收json结果?
我提到过,但运气不好。当我在地址栏中使用以下链接时,浏览器显示json数据如何使用jquery ajax接收json结果?,ajax,json,jquery,Ajax,Json,Jquery,我提到过,但运气不好。当我在地址栏中使用以下链接时,浏览器显示json数据 http://xxxx.xxx.com:1234/products.json//仅示例链接 但当我尝试以下代码时 $.ajax({ url : 'http://xxxx.xxx.com:1234/products.json', dataType: 'json', async: false,
http://xxxx.xxx.com:1234/products.json
//仅示例链接
但当我尝试以下代码时
$.ajax({
url : 'http://xxxx.xxx.com:1234/products.json',
dataType: 'json',
async: false,
success: function(data) {
alert( "test" );
},
error : function() {
alert("Sorry, The requested property could not be found.");
}
});
它总是显示错误消息。我的方法有什么问题?您是否通过JSON Lint之类的验证器运行JSON,以检查它是否100%有效?您是否控制内容?除非其他域明确允许,否则您无法从其他域获取内容,而该站点可能不允许。(链接无论如何都不起作用。)将错误处理程序更改为`error:function(xhr,status,error){alert(“error:+status+':'+error+':'+xhr.responseText);}`@Sharun,这意味着您请求的服务器不支持JSONP。如果它也不执行CORS,那么您唯一的选择就是使用浏览器以外的其他东西来发出请求(例如您的服务器)