Comparison of four external data formats in Ajax

Source: Internet
Author: User

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.

JavaScript

JavaScript files provide great flexibility, but they are not a real data storage mechanism.

Json

Advantage: the structure of the Json file makes it easy to reuse. They are also very concise and easy to read and fast to read.

Disadvantage: 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 people.

XML

Advantage: the portability of XML documents is well-deserved, and XML has become a "world" in the Web service field ". Xpath, dtd, and so on are all added to it, which can validate the format effectively.

Disadvantage: 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 external data is generally the easiest to provide with HTML fragments without sharing data with other applications. 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.

  1. How to determine AJAX requests in PHP
  2. Cross-origin AJAX Solution
  3. Introduction to the use of Ajax in ASP. Net

Related Article

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.