2010-12-06 66 views
1

什麼服務器響應導致瀏覽器Ajax處理程序發生ajaxError? 此錯誤代碼是否與200不同或不是特殊的json字段?什麼是ajax錯誤?

回答

1

是的,非200響應代碼可以導致錯誤,you can see what constitutes "success" here

httpSuccess: function(xhr) { 
    try { 
     // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450 
     return !xhr.status && location.protocol === "file:" || 
      xhr.status >= 200 && xhr.status < 300 || 
      xhr.status === 304 || xhr.status === 1223; 
    } catch(e) {} 

    return false; 
} 

這是在jQuery 1.4.4的,以前的0狀態代碼也是成功的,因爲歌劇304是作爲0報告......寬恕從那以後被刪除了爲消滅成功的誤報。如果上面的檢查是false,the error handler is called