0
有没有办法在IE9中的ajax调用中检查与服务器的连接状态?IE9 - 检查服务器连接状态
林在支持XHR的浏览器使用此:
AJS.$.ajax({
url : "path_to_server",
type : 'DELETE',
async:false,
data:JSON.stringify(resquestData)
}).done(function(){
doSomething();
}).fail(function(response,textStatus, xhr){
if(xhr.code == 19){ // where i check if it is a NetworkError
alert("connection lost");
}else{
alert("error");
}
}
);
我的问题是,我不能让这个解决方案在IE9(或更少)的作品,因为浏览器不支持XHR(XmlHttpRequest的)。任何方案?
问候
[编辑]
我尝试了AJAX功能之前创建的ActiveXObject:
AJS.$("#import").click(function() {
var xmlhttpie;
if (window.ActiveXObject) {
try {
xmlhttpie = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttpie = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
xmlhttpie = false;
}
}
}
AJS.$.ajax({
url : "path_to_server",
type : 'DELETE',
async:false,
data:JSON.stringify(resquestData)
}).done(function(){
doSomething();
}).fail(function(response,textStatus, xhr){
if(xhr.code == 19){ // where i check if it is a NetworkError
alert("connection lost");
}else{
alert("error");
}
}
);
}
但在IE9调试(内部的Ajax功能),当我得到这个(其中“ A“是xmlhttpie):
链接 - >http://prntscr.com/4o9grh
谢谢乔治我会尽力 – 2014-09-19 10:20:58
可能工作,如果你能够称之为阿贾克斯。 – 2014-09-19 10:22:28
不幸的是,这不起作用 – 2014-09-19 11:00:54