模拟超时URL

时间:2013-01-24 12:56:24

标签: javascript timeout

我正在尝试从网页模拟超时,以便我可以实现“处理超时”功能。

基本上我需要的是一个在X秒内没有回复的内容的URL。

提前致谢

这是我的代码:

var req = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance();
req.overrideMimeType('text/plain; charset=utf-8');
req.open("GET", configurationURL, false);
req.variable = specificConfigurationURLTerminator;
setTimeout(function() {
    alert("aborting");
    req.abort();
}, this.configurationRetrievalTimeout);
req.send(null);

2 个答案:

答案 0 :(得分:5)

伙计们非常感谢你们的迅速回复。我找到了我要找的东西:

http://www.google.com:81/

基本上没有响应甚至没有错误=)正是我需要触发超时

答案 1 :(得分:0)

使用.delay(duration)jquery函数。持续时间将以毫秒为单位。 ex- $('div')。延迟(1500);