Home >Web Front-end >JS Tutorial >XMLHttpRequest processes return data in xml format (sample code)_jquery

XMLHttpRequest processes return data in xml format (sample code)_jquery

WBOY
WBOYOriginal
2016-05-16 17:13:371445browse

Sample code:

Copy code The code is as follows:

//Callback function
function callback() {
//alert(xmlhttp.readyState);
//5. Receive response data
// Determine whether the object's status is interaction completed
if (xmlhttp.readyState == 4) {
// Determine whether the http interaction is successful
if (xmlhttp.status == 200 ) {
//Use responseXML to receive the DOM object of the XML data object
var domObj = xmlhttp.responseXML; lt;message>123123123                                                                                               ageNodes.length > 0 ) {
                                                  // Get the text content in the message node Child node
                                                                                                                                                                                                    Return The text content of the text node
var responseMessage = textNode.nodeValue;

                                                                                                                                                                                                                                                                                                    ; 🎜>                                                                                                                                    HTML content in the node
divNode.innerHTML = responseMessage;
} else {
🎜>                                                                                                     else {
         alert("The XML data format is wrong, the original text content is: " xmlhttp.responseText); > }
}}



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn