XMLHttpRequest的timeout在firefox<12 版本无效的,可以重写XMLHttpRequest的timeout对象
// snip to = function() { attempt++; if( attempt < 5) send(); else if( !silent) { console.log("Request Timeout\nFailed to access "+url); } }; // snip var send = function() { if( loader && attempt != 0) { loader.children[0].firstChild.nodeValue = "Error... retrying..."; loader.children[1].firstChild.nodeValue = "Attempt "+(attempt+1)+" of 5"; } a = new XMLHttpRequest(); a.open("POST","/ajax/"+url,true); a.onreadystatechange = rsc; setTimeout(function () { /* vs. a.timeout */ if (a.readyState < 4) { a.abort(); } }, 5000); a.onabort = to; /* vs. a.ontimeout */ a.setRequestHeader("Content-Type","application/json"); a.send(data); console.log(‘HTTP Requesting: %s‘, url); };
解决XMLHttpRequest的timeout在firefox<12版本无效,布布扣,bubuko.com
解决XMLHttpRequest的timeout在firefox<12版本无效
原文地址:http://www.cnblogs.com/kennyhr/p/3860999.html