ie7不能使用ajax,求解决方法
发布网友
发布时间:2022-04-27 19:04
我来回答
共4个回答
热心网友
时间:2022-04-27 20:33
if (window.XMLHttpRequest) {
var req = new XMLHttpRequest();
return req;
}
if (window.ActiveXObject) {
var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
var o;
for (var i = 0; i < prefixes.length; i++) {
try {
// try to create the objects
o = new ActiveXObject(prefixes[i] + ".XmlHttp");
return o;
}
catch (ex) {};
}
}
热心网友
时间:2022-04-27 21:51
function PublicAjax(File,Data,TheObj,OpenMethod) {
var PubXML = false;
try {
PubXML = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
PubXML = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
PubXML = false;
}
}
if (!PubXML && typeof XMLHttpRequest != 'undefined') {
PubXML = new XMLHttpRequest();
}
if(PubXML) {
PubXML.onreadystatechange=function() {
if(PubXML.readyState==4) {
if(PubXML.status==200) {
if (TheObj!="None") {
document.getElementById(TheObj).innerHTML=PubXML.responseText
} else {
eval(PubXML.responseText)
}
}
}
};
PubXML.open(OpenMethod,File,true);
PubXML.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
PubXML.send(Data);
}
}
//
PublicAjax(Url,Data,'fileContent',OpenMethod);
//html部分
<div id="fileContent"></div>
请加分
热心网友
时间:2022-04-27 23:26
dd