|Article Introduction: Ajax and Web service data formats: XML SOAP HTML.|
The term Ajax is abused by developers and sales people. Today's word, which is supposed to be all caps, has become a new word, indicating the transfer of data without refreshing the page. The reasons are:
Ultimately, you have to transfer data between two devices regardless of the technology you use. This is the first part of the Rockux serial data format, and we'll talk about more data and features later.
In the beginning, XML is the best choice. Many languages have functions that support XML format parsing and serialization. Even if the language you're using doesn't support XML, he's actually a piece of text.
1 2 3 4 5 6 7 8 9" (+)
<?xml version= "1.0"?> <products> <book> <title>the principles of Beautiful Web design, 2nd edition</title> <url>http://www.sitepoint.com/books/design2/</url> <author>jason Beaird </author> <publisher>SitePoint</publisher> <price currency= "USD" >39.95</price> </ Book> <book> <title>jquery:novice to ninja</title> <url>http://www.sitepoint.com/books/ Jquery1/</url> <author>earle Castledine & Craig sharkie</author> <publisher>sitepoint </publisher> <price currency= "USD" >29.95</price> </book> <book> <title>build Yo ur Own Database driven website</title> <url>http://www.sitepoint.com/books/phpmysql4/</url> < Author>kevin yank</author> <publisher>SitePoint</publisher> <price currency= "USD" >39.95 </price> </book> </products>
The benefits of XML are:
However, XML also has its drawbacks:
1 2 3 4
Grab value in <data> element var xml = xhr.responsexml; var nodes = xml.getelementsbytagname ("data"); var data = (nodes.length > 0 nodes.firstchild.nodevalue : null);
Many developers think XML is dead, but I don't agree that XML may not be the best choice for Ajax right now, but you don't know how all Web services are deployed. And the popularity of XML is a great thing, don't ignore it.
SOAP is a standard format for data interchange. The detailed technical details document has hundreds of pages, and overall, SOAP relies on well-defined XML schemas.
Few developers in the world use SOAP (see enough). The beauty of soap is that the client's library can automatically convert the XML into native objects. Like what. NET developers can create a SOAP-based network service that clients do not need to do much. As developers, most of them use C #, and they don't care what remote machines use.
But the disadvantage of soap:
Soap is still the choice between service-side communication, especially in the case of the same LAN. But not much in Ajax.
If you want to insert code into a page via an AJAX request, HTML is a simple format that does not require much processing. For example, suppose you need to display a shopping cart on every page. You already have such HTML code on the server side that you can return the same HTML code after you have purchased the opinion item.
Its benefits include:
But there are also disadvantages:
In the following article in Rockux we will talk about:
Reprint Please specify:
Author: rockux–web Front end
From: Ajax and Web Service data formats: XML SOAP HTML