首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

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

2012-06-06 
ajax提交数据 如何设置超时时间例:$.post(index.php/index/index,{id:10,user:user},function(data)

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);          }        }); 

热点排行
Bad Request.