Comparison of four external data formats in AJAX

Source: Internet
Author: User
1. html
Advantage: html snippets only require a small amount of work. External data in this format can be loaded and inserted to the page in a simple way, and even the callback function does not need to be used. Data does not need to be traversed.
Disadvantage: Poor reusability. External files must be closely integrated with their target containers.
2. JavaScript
JavaScript files provide great flexibility, but they are not a real data storage mechanism.
3. json
Advantages:
The structure of the json file makes it easy to reuse. They are also very concise and easy to read and fast to read.
Disadvantages:
Errors in the json file may cause the script on the page to stop running silently, or even cause other negative effects. Therefore, such data must be carefully constructed by trusted users.
4. xml
Advantages:
The portability of xml documents is a well-deserved leader. xml has become a "World Language" in the web service field ". Xpath, dtd, and so on are all added to it, which can validate the format effectively.
Disadvantages:
Xml files are relatively large in size, and the speed of parsing and operating them is slower.

Summary:
By analyzing the advantages and disadvantages of the above data formats, we know that providing external data with html fragments is generally the easiest way to share data with other applications without having to share data. If data needs to be reused and other applications may be affected, json with advantages in performance and file size is usually a good choice. When remote applications are unknown, xml can provide the most reliable guarantee for good interoperability.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.