Ajax data format: XML Html JSON

Source: Internet
Author: User

    1. Xml

      Advantages:

      One of the big advantages of XML is that it is an extensible format that, when used, is not subject to a predetermined data structure, but is free to define the desired structure as long as the structure remains consistent throughout the document. Another benefit of XML is that it conforms to the DOM standard, as long as the data obtained through AJAX calls can be parsed like ordinary HTML documents through getElementsByTagName (), getattribute (), ParentNode, FirstChild and other methods or properties to parse it.

      Disadvantages:

      Cannot be used for Ajax calls across domain names, and each AJAX call requests an XML file that must be in the same domain as the script executing the call, or the request fails. Therefore, public data sources are generally less likely to be in XML format.

===========================================================================================

2. HTML

Advantages:

Speed, without the need to write JavaScript code to parse the acquired HTML, this will not only save the developer experience, but also shorten the load time for users to visit the site.

Disadvantages:

If you want to update a piece of content in the document asynchronously, it's a good way to use HTML as the data source.

However, unlike XML or JSON, it does not provide developers with a granular control, unless you want to update content in a fixed position in an HTML document.

===========================================================================================

3.JSON

Advantages:

JSON is a very fast, flexible, platform-independent format. The JSON format is very easy to use across sites, and most network services provide data in JSON format.

Disadvantages:

The syntax is strictly---each comma, colon, and quotation mark of the JSON is placed in place so that the data can be parsed correctly.

Security---When using a JSON service provided by a third-party network service, the JSON object is easily injected with malicious text, and when used, only the JSON data should be fetched from the trusted data source.

Ajax data format: XML Html JSON

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.