ajax 超时
来源:互联网 发布:深圳网络推广软件 编辑:程序博客网 时间:2024/04/29 19:08
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script type="text/javascript" src="prototype.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<script type="text/javascript">
function callInProgress(xmlhttp) {
switch (xmlhttp.readyState) {
case 1: case 2: case 3:
return true;
break;
// Case 4 and 0
default:
return false;
break;
}
}function showFailureMessage() {
alert('uh oh, it looks like the network is down. Try again shortly');
}// Register global responders that will occur on all AJAX requests
Ajax.Responders.register({
onCreate: function(request) {
request['timeoutId'] = window.setTimeout(
function() {
// If we have hit the timeout and the AJAX request is active, abort it and let the user know
if (callInProgress(request.transport)) {
request.transport.abort();
showFailureMessage();
// Run the onFailure method if we set one up when creating the AJAX object
if (request.options['onFailure']) {
request.options['onFailure'](request.transport, request.json);
}
}
},
5000 // Five seconds
);
},
onComplete: function(request) {
// Clear the timeout, the request completed ok
window.clearTimeout(request['timeoutId']);
}
});
//debugger;
testAjaxRequest();
function testAjaxRequest() {
//$('testButton').disabled = 'true';
var url = '/Default2.aspx';
var myAjax = new Ajax.Request(
url,
{
method: 'get',
requestTimeout:1,
onSuccess:showResponse ,
onTimeout: function() {
alert("onTimeout");
},
onComplete: function() { },
onException: function(e) { alert('onException(e): ' + e) }
}
);
}
//$('testButton').disabled = ''
function showResponse(originalRequest) {
alert('showResponse: ' + originalRequest.responseText);
}
function pause(millisecondi)
{
var now = new Date();
var exitTime = now.getTime() + millisecondi;
while(true)
{
now = new Date();
if(now.getTime() > exitTime) break;
}
alert("wan le");
}
</script>
</div>
</form>
</body>
</html>
- ajax 超时
- ajax超时
- jQuery - ajax超时处理
- jquery ajax超时设置
- ajax 超时设置
- ajax 超时控制
- Ajax请求超时问题
- jquery ajax超时设置
- ajax请求超时处理
- jquery ajax超时设置
- jquery ajax超时设置
- jquery ajax超时设置
- Ajax超时处理
- ajax请求超时
- jquery ajax超时设置
- jquery ajax超时设置
- ajax请求超时设定
- jquery ajax超时设置
- MyEclipse 的快捷键 大全!
- java验证码及其刷新
- ASP.NET中防止页面多次提交的代码
- 译言突然无法访问,疑似被封
- 结束即开始
- ajax 超时
- 程序员值得关注的网站
- CSS的种类:类/标签样式/ID选择符/伪类
- 关于 用java 程序将字符串 保存为 windows ANSI编码格式 txt 文本的 问题解决
- 魔术的起源与发展
- DB2数据库导出表结构与导入导出表数据
- FLEAPHP框架的目录结构
- 有意思的Sql难题
- 在使用INV中如何减少内存的消耗