ajax提交数据 怎么设置超时时间
例:$.post("index.php/index/index",{'id':10,'user':user},function(data){
alert('data');
})
用的是jquery,这里通过post提交数据 然后返回个data数据,如果后台程序长时间没有返回(可能已经卡死掉了),如何设置个超时时间(如5秒),当超过5秒时,让data的值为false
------解决方案--------------------
有timeout这个选项的。
- HTML code
$.ajax({ type: "POST", url: "test.php", timeout:2000, error: function(){ alert(6546); } });