关于PHP+ajax 浏览器兼容问题 IE下正常。前辈麻烦指教下 10
functiongetName(url){varoXmlHttp=new_object();oXmlHttp.Open("POST",url,false);oXmlHtt...
function getName(url)
{
var oXmlHttp = new_object();
oXmlHttp.Open("POST", url, false);
oXmlHttp.setRequestHeader("Content-Type", "text/xml");
oXmlHttp.setRequestHeader("charset", "utf-8");
oXmlHttp.Send();
var text=oXmlHttp.responseText;
delete oXmlHttp;
return text;
}
27 分钟前 tz6060996 | 十一级
看来问题应该出在function new_object() ,没调试你这段代码,你可以直接换成下面这段试试:
//创建求XMLHttpRequest对象
function new_object(){
var RetValue;
try {
RetValue = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
RetValue = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
RetValue = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
RetValue = false;
}
}
}
if (!RetValue){
alert("错误,无法请求XMLHttpRequest!");
}
reutrn RetValue;
}
前辈。关于你刚才给我修改的这段代码。一点反应都没啊。我应该怎么做好吖?求求指教!
原代码是可以IE下使用的。但在其他浏览器不兼容!
function getName(url)
{
var oXmlHttp = new_object();
oXmlHttp.Open("POST", url, false);
oXmlHttp.setRequestHeader("Content-Type", "text/xml");
oXmlHttp.setRequestHeader("charset", "utf-8");
oXmlHttp.Send();
var text=oXmlHttp.responseText;
delete oXmlHttp;
return text;
}
function new_object() {
var RetValue;
try {
RetValue = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
RetValue = new ActiveXObject("Microsoft.XMLHTTP");
} catch (oc) {
RetValue = null;
}
}
if(!RetValue && typeof XMLHttpRequest != "undefined")
RetValue = new XMLHttpRequest();
if (!RetValue)
dvajax_debug("Could not create connection object.");
return RetValue;
} 展开
{
var oXmlHttp = new_object();
oXmlHttp.Open("POST", url, false);
oXmlHttp.setRequestHeader("Content-Type", "text/xml");
oXmlHttp.setRequestHeader("charset", "utf-8");
oXmlHttp.Send();
var text=oXmlHttp.responseText;
delete oXmlHttp;
return text;
}
27 分钟前 tz6060996 | 十一级
看来问题应该出在function new_object() ,没调试你这段代码,你可以直接换成下面这段试试:
//创建求XMLHttpRequest对象
function new_object(){
var RetValue;
try {
RetValue = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
RetValue = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
RetValue = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
RetValue = false;
}
}
}
if (!RetValue){
alert("错误,无法请求XMLHttpRequest!");
}
reutrn RetValue;
}
前辈。关于你刚才给我修改的这段代码。一点反应都没啊。我应该怎么做好吖?求求指教!
原代码是可以IE下使用的。但在其他浏览器不兼容!
function getName(url)
{
var oXmlHttp = new_object();
oXmlHttp.Open("POST", url, false);
oXmlHttp.setRequestHeader("Content-Type", "text/xml");
oXmlHttp.setRequestHeader("charset", "utf-8");
oXmlHttp.Send();
var text=oXmlHttp.responseText;
delete oXmlHttp;
return text;
}
function new_object() {
var RetValue;
try {
RetValue = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
RetValue = new ActiveXObject("Microsoft.XMLHTTP");
} catch (oc) {
RetValue = null;
}
}
if(!RetValue && typeof XMLHttpRequest != "undefined")
RetValue = new XMLHttpRequest();
if (!RetValue)
dvajax_debug("Could not create connection object.");
return RetValue;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询