2014-09-11 54 views
0

如标题所示,我有jsonp跨域ajax查询。它返回json列表和我可以监视它从萤火虫,但在jQuery的ajax功能错误:部分工作,尽管错误状态200 OK,状态文本成功。调用jsonp类型ajax在firebug中返回json,但在ajax中触发错误

我无法访问远程服务器,因此我无法配置CORS。远程服务器只提供返回json列表的webservice。

- 我的AJAX功能

$.ajax({ 
    crossDomain: true, 
    type: 'GET', 
    url: "url/for/json", 
    dataType: "jsonp",   
    success: function(data, success){ 
     console.log(" success "); 
    }, 
    error: function(error){ 
      alert(JSON.stringify(error)); 
     }, 
}); 

--response的萤火

firebug screenshot

- 兼警报称为误差部分(里面没有成功拼命地跑代码)

enter image description here

返回的json我的测试是有效的。

我可以在firebug中监控我所有的json数据,一切正常,但我无法访问浏览器内部的数据(javascript)。我尝试了几乎所有我在网上发现的一切,但没有任何帮助。是否有响应

回答

0
$.ajax({ 
    crossDomain: true, 
    type: 'GET', 
    url: "url/for/json", 
    dataType: "jsonp",   
    success: function(data, success){ 
     console.log(" success "); 
     console.log(data) // here you will have access to the response. 
    }, 
    error: function(error){ 
      alert(JSON.stringify(error)); 
     }, 
}); 

在成功回调来访问数据的方式,你将有机会获得返回的数据。

+0

我试过了。但成功部分内的任何代码都不会被编译,即。 ajax直接调用错误部分。 – Erlan 2014-09-11 12:06:26