AJAX processing method for XML returned by server

亚连
Release: 2018-05-25 11:47:31
Original
1796 people have browsed it

This article mainly introduces the AJAX processing method of XML returned by the server. The example analyzes the implementation skills of Ajax and the processing method of XML return data. Friends in need can refer to the following

The examples of this article describe AJAX processing method for XML returned by the server. Share it with everyone for your reference. The specific analysis is as follows:

In AJAX, if the server side returns an XML document, it can obtain the XML data through the responseXML attribute of the asynchronous object. Developers can use DOM related methods to process it.

Assume that the XML document returned by the server is as follows:

  Member List  isaac W13 Jun 24th Cancer 1118159   fresheggs W610 Nov 5th Scorpio 1038818   girlwing W210 Sep 16th Virgo 1307994   tastestory W15 Nov 29th Sagittarius 1095245   lovehate W47 Sep 5th Virgo 6098017   slepox W19 Nov 18th Scorpio 0658635   smartlau W19 Dec 30th Capricorn 0006621   tuonene W210 Nov 26th Sagittarius 0091704   dovecho W19 Dec 9th Sagittarius 1892013   shanghen W42 May 24th Gemini 1544254   venessawj W45 Apr 1st Aries 1523753   lightyear W311 Mar 23th Aries 1002908  
Copy after login

The client obtains the XML data from the server and displays it in in the table. The code is as follows:

   responseXML   


Name Class Birthday Constellation Mobile
Copy after login

We can see that the code to obtain the XML file on the client is as follows:

Copy after login

In other words, the XML data is obtained directly. In actual development, the work of returning XML data is dynamically generated through server-side (such as ASP.NET, JSP, etc.) code. In other words, the file address in getXML('...') should be the suffix of a dynamic page such as .aspx or .jsp.

Use jQuery framework to implement

If you use jQuery framework on the client, implement AJAX to obtain the XML data on the server side.

The code is as follows:

demo
         
         

Name Class Birthday Constellation Mobile
Copy after login

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

Detailed explanation of ajax synchronization and asynchronousness in jquery

How to implement ASP.NET and Ajax

How JQuery ajax returns JSON

The above is the detailed content of AJAX processing method for XML returned by server. For more information, please follow other related articles on the PHP Chinese website!

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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!