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.
- How to determine AJAX requests in PHP
- Cross-origin AJAX Solution
- Introduction to the use of Ajax in ASP. Net