人生本是一个不断学习的过程,在这个过程中,图老师就是你们的好帮手,下面分享的AJAX教程(14):通过XMLHTTP加载XML文件懂设计的网友们快点来了解吧!
【 tulaoshi.com - Web开发 】
通过XMLHTTP加载XML文件:
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/webkaifa/)html
head
script type="text/javascript"
var xmlhttp;
function loadXMLDoc(url)
{
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.onreadystatechange=state_Change;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
else
{
alert("Your browser does not support XMLHTTP.");
}
}
function state_Change()
{
if (xmlhttp.readyState==4)
{// 4 = "loaded"
if (xmlhttp.status==200)
{// 200 = "OK"
document.getElementById('A1').innerHTML=xmlhttp.status;
document.getElementById('A2').innerHTML=xmlhttp.statusText;
document.getElementById('A3').innerHTML=xmlhttp.responseText;
}
else
{
alert("Problem retrieving XML data:" + xmlhttp.statusText);
}
}
}
/script
/head
body
h2Using the HttpRequest Object/h2
pbStatus:/b
span id="A1"/span
/p
pbStatus text:/b
span id="A2"/span
/p
pbResponse:/b
br /span id="A3"/span
/p
button onclick="loadXMLDoc('/example/xmle/note.xml')"Get XML/button
/body
/html
来源:http://www.tulaoshi.com/n/20160220/1632552.html
看过《AJAX教程(14):通过XMLHTTP加载XML文件》的人还看了以下文章 更多>>
如果您有什么好的建议或者疑问,可以联系我们。 商务合作QQ:3272218541;3282258740。商务合作微信:13319608704;13319603564。
加好友请备注机构名称。让我们一起学习、一起进步tulaoshi.com 版权所有 © 2019 All Rights Reserved. 湘ICP备19009391号-3
微信公众号