[英]XMLHttpRequest().Open is not a function in firefox but works in chrome
I have the function below but when I try to run it in firefox i get the error "xmlhttp.Open is not a function" this does not happen in google chrome however have I missed some code converting from the ActiveXObject? 我有下面的函数,但是当我尝试在firefox中运行它时,出现错误“ xmlhttp.Open不是一个函数”,这在谷歌浏览器中不会发生,但是我错过了一些从ActiveXObject转换的代码吗? The PAGE parameter is set and works for the ActiveXObject in Internet Explorer
PAGE参数已设置并适用于Internet Explorer中的ActiveXObject
function broker(PAGE,PARAMARR,STARTPARAM)
{
var postdata=getPostData();
var ua=navigator.userAgent;
var msie=ua.indexOf ('MSIE ');
//var xmlhttp =null;
if (msie!=-1)
{
xmlhttp = new ActiveXObject('MSXML2.XMLHTTP');
xmlhttp.Open('POST',PAGE,false);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
}
else {
xmlhttp = new XMLHttpRequest();
xmlhttp.Open('POST',PAGE,false);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
}
var paramno,param;
for (paramno=STARTPARAM;paramno<PARAMARR.length;paramno++)
{
param=PARAMARR[paramno];if (param==void 0) param='';
if (param===true) param=-1;
if (param===false) param=0;
postdata=postdata+'&Parameter='+encodeURIComponent(param);
}
xmlhttp.setRequestHeader('Content-Length', postdata.length);
xmlhttp.send(postdata);
var response=new String(xmlhttp.responseText);
var brkmsg=getMessage(response);
return brkmsg;
}
Chrome: Netscape mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, like gecko) chrome/47.0.2526.106 safari/537.36 Chrome:Netscape Mozilla / 5.0(Windows nt 6.1; wow64)applewebkit / 537.36(khtml,like gecko)chrome / 47.0.2526.106 safari / 537.36
Firefox: Netscape mozilla/5.0 (windows nt 6.1; wow64; rv:43.0) gecko/20100101 firefox/43.0 Firefox:Netscape Mozilla / 5.0(Windows nt 6.1; wow64; rv:43.0)gecko / 20100101 firefox / 43.0
IE11: Netscape mozilla/5.0 (windows nt 6.1; wow64; trident/7.0; slcc2; .net clr 2.0.50727; .net clr 3.5.30729; .net clr 3.0.30729; media center pc 6.0; .net4.0c; .net4.0e; infopath.3; rv:11.0) like gecko) IE11:Netscape mozilla / 5.0(Windows nt 6.1; wow64; trident / 7.0; slcc2; .net clr 2.0.50727; .net clr 3.5.30729; .net clr 3.0.30729; Media Center PC 6.0; .net4.0c; .net4.0e; infopath.3; rv:11.0),例如壁虎)
IE8 (Compatability Mode): Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; WOW64; Trident/4.0; .NET CLR 3.0.4506.2152; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E; InfoPath.2) IE8(兼容模式):Mozilla / 4.0(兼容; MSIE 7.0; Windows NT 5.2; WOW64; Trident / 4.0; .NET CLR 3.0.4506.2152; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET4.0C ; .NET4.0E; InfoPath.2)
Seems to be a typo. 似乎是一个错字。 Write "open" in lower case!
小写“ open”!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.