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.