的jQuery:jQuery的AJAX狀態 「200 OK」,但沒有數據響應
$.ajax({
url : url,
type : 'GET',
dataType: 'json',
data: {
'FN' : 'GetPages',
'PIN' : '7659'
},
xhrFields: {
withCredentials: true
},
crossDomain: true,
success: function(data) {
alert('succsess');
console.log('data', data);
},
error: function (xhr, ajaxOptions, thrownError) {
alert('error');
console.log(xhr.status);
console.log(thrownError);
}
});
螢火蟲的Firefox網絡
Firebug Error http://s14.directupload.net/images/121123/8ar5vljg.png
會發生什麼
的AJAX 「錯誤:」事件得到t riggered我的console.log輸出:
xhr.status -> 0
thrownError -> (empty String)
這是正常的嗎?當我在瀏覽器中鍵入URL時,我收到一個帶有JSON內容的文件下載,這不應該是個問題嗎?
在瀏覽器url上,響應是: [{「pg」:0,「descr」:「PC1」},{「pg」:1,「descr」:「PC2」},{「 PG 「:2」,DESCR 「:」 PC3 「},{」 PG 「:3」,DESCR 「:」 HG1 「},{」 PG 「:4」,DESCR 「:」 HG2 「},{」 PG」 :5, 「DESCR」: 「HG3」},{ 「PG」:6, 「DESCR」: 「HG4」},{ 「PG」:7, 「DESCR」: 「DW1」},{ 「PG」:8 ,「descr」:「DW2」},{「pg」:9,「descr」:「CMN」}] – user1841515
另外我的理解是** jsonp **不會工作原因我不允許改變任何東西服務器和它的響應將保持json格式,而不是jsonp格式 – user1841515
jsonp不會影響服務器。但它可以幫助解決CORS問題。這可能是你唯一的選擇,無需修改服務器 – JonWells