write it in front.
The data that Ajax obtains from the server is a string, but with different parsing, it can be parsed into XML or JSON for application.
Generally speaking. Data in XML format is more common, but the server and client are more complex to parse, while using JSON statements, the service side needs to do more work, but to the client, by using the Eval () function to parse, you will get the JS object, It is very convenient to use. In the course of use, which method to use, according to the actual needs of the project, it is recommended: In the case of using JSON, try to use JSON.
See examples for specific usage.
Example
1.XML Data User.xml
<?xml version= "1.0" encoding= "Utf-8"?><users> <user> <username> Zhang San xml</ username> <age>33</age> </user> <user> <username> John Doe xml</ username> <age>34</age> </user></users>
2.JSON Data User.js
[ {username: "Zhang San json", age:33}, {username: "John Doe JSON", age:34}]
3.HTML page Code
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
Effect
Run the page and click the "Load XML data" button to read the data from the XML data file and add it to the table; Click the "Load JSON data" button to read the data from the JS file and add it to the table.
Ajax gets data from the server---the original eco-Ajax