In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article focuses on "how to create XML HttpRequest objects", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to create a XML HttpRequest object.
Utl.js
The code is as follows:
Function createXmlTree (node, indent) {
If (node = = null)
Return ""
Var str = ""
Switch (node.nodeType) {
Case 1: / / Element
Str + = ""
Str + = ">"
Var cs = node.childNodes
For (var I = 0; I
< cs.length; i++) str += createXmlTree(cs[i], indent + 3); str += ""; break; case 9: // Document var cs = node.childNodes; for (var i = 0; i < cs.length; i++) str += createXmlTree(cs[i], indent); break; case 3: // Text if (!/^\s*$/.test(node.nodeValue)) str += "" + node.nodeValue + ""; break; case 7: // ProcessInstruction str += "" break; case 4: // CDATA str = "" + node.nodeValue + "]" + "]>"
Break
Case 8: / / Comment
Str = ""
Break
Case 10:
Str = ""
/ / TODO: Handle custom DOCTYPE declarations (ELEMENT, ATTRIBUTE, ENTITY)
Break
Default:
/ / alert (node.nodeType + "\ n" + node.nodeValue)
Inspect (node)
}
Return str
}
Function inspect (obj) {
Var str = ""
For (var k in obj)
Str + = "obj." + k + "=" + obj [k] + "\ n"
Window.alert (str)
}
Function createXmlAttribute (a) {
Return "" + a.nodeName + "=\"+ a.nodeValue +"\ ""
}
The code is as follows:
Ajax test
/ /-XMLHttpObj class-
Function XMLHttpObject (url,Syne) {
Var XMLHttp=null
Var o=this
This.url=url
This.Syne=Syne
This.sendData = function ()
{
If (window.XMLHttpRequest) {
XMLHttp = new XMLHttpRequest ()
} else if (window.ActiveXObject) {
XMLHttp = new ActiveXObject ("Microsoft.XMLHTTP")
}
With (XMLHttp) {
Open ("GET", this.url, this.Syne)
Onreadystatechange = o.CallBack
Send (null)
}
}
This.CallBack=function ()
{
If (XMLHttp.readyState = = 4) {
If (XMLHttp.status = = 200) {
O.debugXML ("readyState:" + XMLHttp.readyState + "")
O.debugXML ("status:" + XMLHttp.status + "")
O.debugXML ("" + createXmlTree (XMLHttp.responseXML,0) + "")
}
}
}
This.getText=function ()
{
If (XMLHttp==null) {return "not loaded XMLHttpRequest"}
If (XMLHttp.readyState==4) {return XMLHttp.responseText}
Return XMLHttp.readyState
}
This.debugXML=function (log)
{
Try {document.getElementById ("XMLDebug") [xss_clean] + = log}
Catch (e) {}
}
}
Var XMLDoc1=new XMLHttpObject ("tree.xml", true)
Tree.xml xtree.xsl Blog
Feed
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.