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

10年的乌拉特中网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。全网营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整乌拉特中建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联从事“乌拉特中网站设计”,“乌拉特中网站推广”以来,每个客户项目都认真落实执行。

本文目录一览

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

有timeout这个选项的。
$.ajax({
type: "POST",
url: "test.php",
timeout:2000,
error: function(){
alert(6546);
}
});

2,ajax load方法 默认有超时时间吗

默认jquery是没有设置这个时间的,应该是看每个浏览器对XMLHttpRequest对象是否有超时处理timeout unsigned longThe number of milliseconds a request can take before automatically being terminated. A value of 0 (which is the default) means there is no timeout.Note: You may not use a timeout for synchronous requests with an owning window.如果超时了,会触发jquery的ajax中断abort事件。当然自己可以手动设置时间ajax里有个timeout :毫秒,

在同一文件夹下,可以直接写text.txt就可以的

3,ajax如何设置超时时间

<script type=”text/javascript”>

function getXMLHttpRequest()
{
var xhr = false;
if ( window.XMLHttpRequest )
{
xhr = new XMLHttpRequest();
if ( xhr.overrideMimeType )
{
xhr.overrideMimeType(”text/xml”);
}
}else if ( window.ActiveXObject )
{
try{
xhr = new ActiveXObject(”Msxml2.XMLHTTP”);
}catch(e)
{
try{
xhr = new ActiceXObject(”Microsoft.XMLHTTP”);
}catch(e)
{
xhr = false;
}
}
}

return xhr;
}

window.onload = function()
{
var _x = getXMLHttpRequest(); //获得XMLHttpRequest对象
if ( !_x ) return false;
_x.open(”get”,http://www.baidu.com,true);
_x.onreadystatechange = function()
{
if ( _x.readyState == 4 && _x.status == 200 )
{
clearTimeout(clearTO); //如果准备状态成功,并且HTTP状态码正确则清除setTimeout
alert(”Success”);
}
};
var cleaeTO = setTimeout(function() /*重点,在请求发布后开始设置setTimeout,如果请求状态不成功也就是readyState != 4 那么setTimeout将会在5秒后运行,并弹出信息提示,要是请求成功,将会清除该setTimeout*/
{
_x.abort(); //终止XMLHttpRequest对象
alert(”系统异常,请您刷新页面或稍后再试….”);
},50000);
_x.send(null);
};
</script>


当前文章:ajax设置超时时间,ajax提交数据怎么设置超时时间
文章网址:http://pwwzsj.com/article/ehedsj.html