Ajax response data can be any format like HTML, XML, JSON. Below are some comparisons of XML & JSON.
XML
- XML parsing is generic.
- XML is a markup language and has semantics.
- XML is most easily readable format for humans.
- Easily validate the data using schema.
JSON
- JSON data is faster than XML over the Http.
- Scripts for JSON data are simpler than XML.
- For i18n, JSON seems to be an easy one.
- Its very hard to read humans.
To conclude, based on your requirements you can choose the format either XML or JSON.
If you are new to Ajax or JSON. Kindly read the below links for learning basics.
Ajax – https://manikandanmv.wordpress.com/2008/09/23/ajax-asynchronous-javascript-and-xml/
JSON – https://manikandanmv.wordpress.com/2008/10/08/json-java-script-object-notation/
Tags: AJAX JSON, AJAX response, AJAX XML, JSON, JSON responss, XML, XML response, XML vs JSON
January 17, 2009 at 7:57 pm |
For me have cases when JSON is better, but have other cases when XML is better in AJAX
January 19, 2009 at 4:50 am |
miro,
yes.., depends on the requirement or needs we have to choose the result format (JSON or XML)
January 19, 2009 at 10:23 pm |
JSON is better for using from JavaScript
January 21, 2009 at 6:50 am |
absolutely right miro, using javascript you can easily parse the JSON data from client side.