读书人

见鬼了该死的firefox真是搞死小弟我

发布时间: 2012-02-05 12:07:14 作者: rapoo

见鬼了,该死的firefox真是搞死我了,请高人看看我的程序有什么问题
js脚本————————————————
<html>
<body>

<script type= "text/javascript ">
var request_xmlHttp = null;
var xmlDom = null;
var url = "http://localhost/house/WebForm1.aspx ";

function GetXmlHttp(){
var obj=null;
if(window.ActiveXObject){
alert( "ie ");
obj=new ActiveXObject( "Microsoft.XMLHTTP ");
}else{
alert( "ff ");
obj=new XMLHttpRequest();
}
return (obj);
}

function GetXmlDom(){
if(document.all)
return new ActiveXObject( "Msxml.DOMDocument ");
else if(document.implementation && document.implementation.createDocument)
return document.implementation.createDocument( "text/xml ", " ",null);
else
alert( 'Your browser cannot handle this script ');
}

request_xmlHttp = GetXmlHttp();
if(request_xmlHttp != null){
xmlDom= GetXmlDom();
request_xmlHttp.open( "POST ",url,true);
request_xmlHttp.setRequestHeader( "Content-Type ", "application/x-www-form-urlencoded ");
request_xmlHttp.onreadystatechange=RSchange;
request_xmlHttp.Send(null);
}else{
document.write( "can 't create xmlHttp ");
}

function RSchange(){
if (request_xmlHttp.readyState==4){
if(request_xmlHttp.status != 200){
document.write( "发生错误: "+request_xmlHttp.statusText+ " <br> 出错原因: "+request_xmlHttp.responseText);
}else{
if(window.ActiveXObject){
xmlDom.load(request_xmlHttp.ResponseStream);
}else{
xmlDom.load(request_xmlHttp.responseXML);
}
OutPutResult(xmlDom);
}
}
}

function OutPutResult(objDom){
document.write(objDom.getElementsByTagName( "root ")[0].firstChild.nodeValue);
}
</script>

</body>
</html>


服务器代码(.NET)-------------------------
XmlDocument xmlDom = new XmlDocument();
xmlDom.LoadXml( " <root> </root> ");
xmlDom.SelectSingleNode( "//root ").InnerText = "hello world ";
Response.ContentType = "text/xml ";
xmlDom.Save(Response.OutputStream);
Response.End();

ie下运行正常,ff下在open的时候就出错了,不知道是什么原因

[解决办法]
开源的 prototype jquery 为什么不用?? 自己写兼容性问题挺麻烦的.
[解决办法]
贴出错误!
[解决办法]
没使用过FireFox,第一次在CSDN上说话,顶一下:)
[解决办法]
FF的话get请求
send需要有参数比如ajax.send(null);
[解决办法]
哈哈,应当是跨域了,XMLHTTP的open方法抛出这个错误,一般都是跨域引起的...

你看你的当前打开页面的URL,是不是跟localhost一样的.

读书人网 >JavaScript

热点推荐