請考慮下面的代碼片段:回調 - Parseerror JSONP通過jQuery AJAX
$(function() {
$.ajax({
type: "GET",
url: "http://mosaicco.force.com/siteforce/activeretailaccounts",
dataType: "jsonp",
crossDomain: true,
jsonp: "callback",
error: function(jqXHR, textStatus, errorThrown) {
alert('Error Message: '+textStatus);
alert('HTTP Error: '+errorThrown);
},
success: function (data) {
var i = 0;
//Process JSON
$.each(data, function() {
var name = this.locname;
var lat = this.lat;
var lng = this.lng;
var address = this.address;
var address2 = this.address2;
var city = this.city;
var state = this.state;
var postal = this.postal;
var phone = this.phone;
var web = this.web;
web = web.replace("http://", "");
var distance = GeoCodeCalc.CalcDistance(orig_lat, orig_lng, lat, lng, GeoCodeCalc.EarthRadiusInMiles);
//Create the array
locationset[i] = new Array(distance, name, lat, lng, address, address2, city, state, postal, phone, web);
i++;
});
}
});
});
我拉JSON跨域出於某種原因,我不斷收到一個parseerror返回:
HTTP Error:Error: jQuery17209875996995251626_1343943259805 was not called
我能夠看到頁面上的數據就好 - 回調看起來像這樣:
callback:jQuery17209875996995251626_1343943259805_:1343943260015
請幫我診斷我錯過了什麼 - 謝謝!
[jQuery JSON響應總是觸發一個ParseError]的可能重複(http://stackoverflow.com/questions/5095307/jquery-json-response-always-triggers-a-parseerror) – Bergi 2012-08-03 15:08:10