⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 codejanitor_timeout.js

📁 ruby on rails web敏捷开发之路第二版 源代码
💻 JS
字号:
//Modified from http://codejanitor.com/wp/2006/03/23/ajax-timeouts-with-prototype///More substantially rewritten than I originally hoped. (stu at relevancellc.com)if (!Ajax.Timeout) {  Ajax.Timeout = {    callInProgress: function(xmlhttp) {      switch (xmlhttp.readyState) {        case 1: case 2: case 3:        return true;        break;        // Case 4 and 0        default:        return false;        break;      }    },    //override in your own applications    handler: function(request) {      alert("Call failed to " + request.url);    },  }}Ajax.Responders.register({  onCreate: function(request) {    if (Ajax.Timeout.globalTimeout) {      request['timeoutId'] = window.setTimeout(        (function() {          if (this.callInProgress(request.transport)) {            request.transport.abort();            this.lastTimeout = request;            this.handler(request);            //prevent status check from failing after abort (?)            request.responseIsSuccess = function() {return false;}            request.respondToReadyState(4);          }        }).bind(Ajax.Timeout),      Ajax.Timeout.globalTimeout * 1000);    }  },  onComplete: function(request) {    if (request['timeoutId']) {      window.clearTimeout(request['timeoutId']);    }  }});  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -