2013-08-27 80 views
1

我收到一个错误,返回一个200成功代码和parseerror响应的jQuery AJAX调用。我假设这意味着jQuery得到的数据,但无法解析它。但是,我可以检索响应数据,它是格式良好的JSON。AJAX返回200成功,但未能解析响应JSON

我正在使用jsonp数据进行跨域服务。

jQuery的

jQuery.ajax({ 
    url: ServiceBasePath + "/json/ZipRiders", 
    dataType: "jsonp", 
    success: function (data) { 
     ... 
    }, 
    error: function (a,b,c) { 
     alert(a, b, c); 
    } 
}); 

错误数据

a: Object { readyState=4, status=200, statusText="success", more...} 
b: "parsererror" 
c: Error: jQuery1101020726428059127155_1377610175566 was not called 

响应

[ 
    { 
    "AdDescription": "Taking 75 north instead of 23 just for fun", 
    "AdID": "---", 
    "CityName": "Highland", 
    "IsWanted": false, 
    "Latitude": "42.656281", 
    "Longitude": "-83.63297", 
    "Name": "Ride to Milford, MI", 
    "NetworkLogon": "---", 
    "RideNotifyEnable": true, 
    "UserName": "---" 
    }, 
    { 
    "AdDescription": "Ride to jackson", 
    "AdID": "---", 
    "CityName": "Jackson", 
    "IsWanted": false, 
    "Latitude": "42.252268", 
    "Longitude": "-84.38842", 
    "Name": "Ride to Jackson, MI", 
    "NetworkLogon": "---", 
    "RideNotifyEnable": true, 
    "UserName": "---" 
    }, 
    { 
     ... 
    }, 
    { 
     ... 
    }, 
    ... 
] 
+0

我想我们必须使用'$ .parseJSON()'使它成为JSON对象。 –

+0

我可以看到完整的json数据吗 –

+5

您正在指定'“jsonp”',但是您要返回JSON。他们不是一回事。 http://stackoverflow.com/questions/3839966/can-anyone-explain-what-jsonp-is-in-layman-terms/3840118#3840118 – Ian

回答

1

远程服务器似乎不甲肝e认出你的jsonp回调。你是否与使用jsonp的API进行通信?

+1

这是一条评论... – War10ck

+1

我会同意它的评论-y,但我相信它也是答案。 –

+0

发现ASP.NET后端的web.config文件未配置为JSONP。 – NargothBond