Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 17:13:37
Original
1414 people have browsed it

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); > }
}}



Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template