AJAX返回200成功,但未能解析响应JSON

AJAX returning 200 success but failing to parse response JSON

本文关键字:响应 JSON 返回 200成功 AJAX      更新时间:2023-09-26

我收到一个错误,jQuery AJAX调用返回200成功代码和响应上的parseerror。我假设这意味着jQuery得到了数据,但无法解析。但是,我可以检索响应数据,它是格式良好的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": "---"
  },
  {
      ...
  },
  {
      ...
  },
  ...
]

远程服务器似乎没有识别您的jsonp回调。您是否正在与支持json的API进行通信?