下一个代码向我显示如下错误:" null'是null或不是对象"仅在IE8上。 IE8显示"} catch(错误){"怎么回事。我一直在研究这个问题。在一篇文章中我发现你可以解决这个问题:window.event。但我不知道在哪里使用它。请帮忙。
<![CDATA[
var sendRequest = function(url, callback, postData) {
try{
var req = createXMLHTTPObject();
if (!req) return;
var method = (postData) ? "POST" : "GET";
req.open(method, url, true);
req.setRequestHeader('User-Agent','XMLHTTP/1.0');
if (postData)
req.setRequestHeader('Content-type','application/x-www-form-urlencoded; charset=UTF-8');
req.timeout = 65000;
req.ontimeout = function () { ajaxRequestTimedOut(); }
req.onreadystatechange = function () {
try{
if (req.readyState != 4) return;
if (req.status != 200 && req.status != 304) {
unlockScreen();
openAlert('<p class="style6" style="text-align: justify;"> Error de comunicación. Presiona Aceptar para continuar.');
lockScreen();
setTimeout(function(){
sendRequest(url, callback, postData);
}, 500);
return;
}
callback(req);
}catch(err){ //IE8 Says this line is wrong
openAlert('<p class="style6" style="text-align: justify;">' + err.message);
}
}
if (req.readyState == 4) return;
//Fix to prevent Aborted messages on IE
req.onprogress = function () { };
req.onerror = function () { };
req.onabort = function(){
unlockScreen();
openAlert('<p class="style6" style="text-align: justify;">' + "Ocurrio un problema, favor de reintentar.");
};
setTimeout(function(){
req.send("SoapRequest=" + escape(postData));
}, 500);
}catch(err){
openAlert('<p class="style6" style="text-align: justify;">' + err.message);
}
};
]]>
出了什么问题?非常感谢你!