w3c的例子有问题?
时间:2010-09-10
来源:互联网
<html>
<body>
<script type="text/javascript">
xmlHttp=null;
if (window.XMLHttpRequest)
{// code for IE7, Firefox, Opera, etc.
xmlHttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{// code for IE6, IE5
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlHttp!=null)
{
xmlHttp.open("GET", "advance.xml", false);
xmlHttp.send(null);
xmlDoc=xmlHttp.responseText;
alert(xmlDoc);
// xmlHttp.open("POST", "demo_dom_http.asp", false);
// xmlHttp.send(xmlDoc);
// document.write(xmlHttp.responseText);
}
else
{
alert("Your browser does not support XMLHTTP.");
}
</script>
</body>
</html>
以上的例子是我在W3C上面复制下来的,值注释了3行。但是运行时提示xmlHttp.open("GET", "advance.xml", false);有错。
advance.xml这个文件也有。并且路径也是对的。
<body>
<script type="text/javascript">
xmlHttp=null;
if (window.XMLHttpRequest)
{// code for IE7, Firefox, Opera, etc.
xmlHttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{// code for IE6, IE5
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlHttp!=null)
{
xmlHttp.open("GET", "advance.xml", false);
xmlHttp.send(null);
xmlDoc=xmlHttp.responseText;
alert(xmlDoc);
// xmlHttp.open("POST", "demo_dom_http.asp", false);
// xmlHttp.send(xmlDoc);
// document.write(xmlHttp.responseText);
}
else
{
alert("Your browser does not support XMLHTTP.");
}
</script>
</body>
</html>
以上的例子是我在W3C上面复制下来的,值注释了3行。但是运行时提示xmlHttp.open("GET", "advance.xml", false);有错。
advance.xml这个文件也有。并且路径也是对的。
作者: blandyzld 发布时间: 2010-09-10
是以http方式测试的吗
作者: net_lover 发布时间: 2010-09-10
http方式?怎么测试?
作者: blandyzld 发布时间: 2010-09-10
就是把你的文件放在站点下测试啊,比如iis,tomcat,而不是
直接点击本地的htm文件
直接点击本地的htm文件
作者: net_lover 发布时间: 2010-09-10
哦!明白了!
作者: blandyzld 发布时间: 2010-09-10
但是这样的话,在本地点击htm文件也可以呀。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
<script type="text/javascript">
xmlhttp=null;
if (window.ActiveXObject)
{
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
else if (window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
if (xmlhttp==null)
{
alert("Your browser does not support XMLHTTP.");
}
if (xmlhttp!=null)
{
xmlhttp.open("GET", "advance.xml", false);
xmlhttp.send(null);
xmlDoc=xmlhttp.responseText;
alert(xmlDoc);
// xmlHttp.open("POST", "demo_dom_http.asp", false);
// xmlHttp.send(xmlDoc);
// document.write(xmlHttp.responseText);
}
else
{
alert("Your browser does not support XMLHTTP.");
}
</script>
</body>
</html>
不明白为什么?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
<script type="text/javascript">
xmlhttp=null;
if (window.ActiveXObject)
{
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
else if (window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
if (xmlhttp==null)
{
alert("Your browser does not support XMLHTTP.");
}
if (xmlhttp!=null)
{
xmlhttp.open("GET", "advance.xml", false);
xmlhttp.send(null);
xmlDoc=xmlhttp.responseText;
alert(xmlDoc);
// xmlHttp.open("POST", "demo_dom_http.asp", false);
// xmlHttp.send(xmlDoc);
// document.write(xmlHttp.responseText);
}
else
{
alert("Your browser does not support XMLHTTP.");
}
</script>
</body>
</html>
不明白为什么?
作者: blandyzld 发布时间: 2010-09-10
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28