ajax status为canceld
因为ajax请求太久,会出现canceled状态,然后尝试把ajax的timeout
值设置为2000,发现ajax请求成功并返回数据。
You can attach an ajaxError handler to document
$(function(){ $(document).ajaxError(function(event, request, settings) { //Do whatever }); });
Edit: To set Ajax timeout globally, you have to use ajaxSetup
$.ajaxSetup({ timeout: 2000 //Time in milliseconds });
Note:$.ajaxSetup
should be set before other Ajax calls.