Difference between AJAX and JSON
AJAX means asynchronous JavaScript and XML. It is basically used for the development of interactive web pages, and is used to communicate with the server without affecting the display or behavior of the current page. One of the best examples where AJAX is implemented when the user sees suggestions that appear in the drop down when one enters a search string in Google. A group of technologies are put together and are collectively referred to as AJAX. JSON (JavaScript Object Notation) is a standard for data interchange that is readable by humans. It is used to represent objects and is derived from JavaScript.
History
In the 1990’s a majority of web pages were static and were completer HTML pages. Even for small changes to be made as a result of a query from the user, the entire web page was loaded from the server again and again. This resulted in wasted bandwidth. Asynchronous loading was introduced for the first time in 1995 when Java Applets came into existence. XMLHTTP ActiveX Control was introduced in 1999 with the emergence of IE 5. In 2004 and 2005, extensive use of AJAX was witnessed in Gmail and Google Maps. It was in 2005 when the term AJAX was coined.
JSON was popularized by Douglas Crockforad. An official website json.org was launched in 2002. Yahoo! and Google were among the first tech companies to use JSON format in some of their web services.
Technologies
AJAX, HTMK, XHTML and CSS are used for mark-up and presentation of the web page. DOM – Document Object Model is used for the dynamic display. XML is used for data interchange. XMLHTTP Request Object is used to communicate asynchronously with the server to avoid full page reloads. And last but not the least JavaScript is used to combine all these technologies. Files written in JSON have an extension .json. It is nothing but a standard format for transmitting data over a network. It is comparable to XML. It is generally used for data transmission between servers and web applications. Various data types used are integers, strings, arrays, Boolean and objects. One can use AJAX to transmit objects in JSON format.
Drawbacks
It is always more difficult to build a web page using AJAX than it is when programming using simple HTML - owing to the dynamic nature. When a part of web page is refreshed using AJAX it is not registered in browser’s history hence the back button would take you directly to the previously opened complete web page. New testing and coding methods have to be implemented to build secure AJAX applications. As a result of increased number of queries, longer response times are noticed most of the time. To solve this problem additional hardware is needed which increases the cost. Some problems related to security have been witnessed with the use of the JSON format. As JavaScript interpreter is used to execute the text in JSON, the program is exposed to potential malicious scripts inside the data retrieved from the Internet.
Similarities and Differences
AJAX
- AJAX means asynchronous JavaScript and XML.
- Used for the development of interactive web pages.
- HTMK, XHTML, DOM, XML, XMLHTTP Request Object and JavaScript are the technologies used.
- There are some drawbacks like separate testing and coding methods and longer response times.
JSON
- JSON (JavaScript object notation) is a standard for data interchange that is readable by humans.
- One might face some security threats while using JSON format.
- Various data types used are integers, strings, arrays, Boolean and objects.
- One can use AJAX to transmit objects in JSON format asynchronously.