2013-01-24 23 views
2

我試圖嘲笑從網頁的超時,以便我可以實現「處理超時」功能。模擬超時url

基本上我需要的是一些在X秒內不回覆的東西的網址。

在此先感謝

這裏是我的代碼:

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); 
+0

難道你們就不能只是包裝的AJAX回報函數在'setTimeout()'裏面? – BenM

+0

@BenM這正是我想要做的,但要測試它,我需要一個URL,肯定會超時,這就是我所追求的。 – ricardoespsanto

+1

請將您正在討論的代碼添加到問題中。 – AD7six

回答

0

使用.delay(持續時間)jQuery的功能。持續時間將以毫秒爲單位。 ex-$('div')。delay(1500);

+0

不能使用jquery ..只有純java :( – ricardoespsanto

+0

@ AD7six你是對的!我的意思是Javascript:p – ricardoespsanto

+3

@Ricky註釋是可編輯的;)(和可刪除的) – AD7six