在IE9中同步使用XMLHttpRequest不会返回任何数据

Using XMLHttpRequest synchronously in IE9 does not return any data

本文关键字:返回 任何 数据 XMLHttpRequest IE9 同步      更新时间:2023-09-26

这是我使用的代码:

if(window.XDomainRequest) {xml_add_http = new XDomainRequest();}
    else if (window.XMLHttpRequest)
        {// code for IE7+, Firefox, Chrome, Opera, Safari
            xml_add_http=new XMLHttpRequest();
        }
    else
{// code for IE6, IE5
    xml_add_http=new ActiveXObject("Microsoft.XMLHTTP");
}
var main_url    =   "http://localhost/date/check.php";
xml_add_http.open("GET",main_url,false);
xml_add_http.send(null);
var xml_add_Doc=xml_add_http.responseText;
console.log(xml_add_Doc);
}

在大厅窗口的chrome或firefox上,它返回:

{"日期时间":"2013年7月4日星期四20:11:21+000"}

但在InternetExplorer9中,它只返回:

日志:

从代码中删除XDomainRequest后,它可以在例如上工作