当前位置: 代码迷 >> JavaScript >> ajax提交数据 怎么设置超时时间
  详细解决方案

ajax提交数据 怎么设置超时时间

热度:223   发布时间:2012-06-06 16:44:11.0
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);
          }
        }); 
  相关解决方案