What is AJAX? Understanding Asynchronous JavaScript and XML
☰Fullscreen
Table of Content:
What is AJAX?
AJAX stands for Asynchronous JavaScript and XML. It is a group of related technologies used to display data asynchronously. In other words, it sends and retrieves data without reloading the web page.
What are the advantages of AJAX?
- Quick Response
- Bandwidth utilization
- The user is not blocked until data is retrieved from the server.
- It allows us to send only important data to the server.
- It makes the application interactive and faster.
What are the disadvantages of AJAX?
- Dependent on JavaScript
- Security issues
- Debugging is difficult
What are the real web applications of AJAX currently running in the market?
- Gmail
- Javatpoint
- Youtube
What are the security issues with AJAX?
- AJAX source code is readable
- Attackers can insert the script into the system
What are the technologies used by AJAX?
- HTML/XHTML and CSS - These technologies are used for displaying content and style.
- DOM - It is used for dynamic display and interaction with data.
- XML - It is used for carrying data to and from server
- XMLHttpRequest - It is used for asynchronous communication between client and server.
- JavaScript - It is used mainly for client-side validation
What is the purpose of XMLHttpRequest?
- It sends data in the background to the server.
- It requests data from the server.
- It receives data from the server.
- It updates data without reloading the page.
What are the properties of XMLHttpRequest?
The important properties of the XMLHttpRequest object are given below.
- onReadyStateChange - It is called whenever readystate attribute changes.
- readyState - It represents the state of the request.
- responseText - It returns response as text.
- responseXML - It returns response as XML.
- status - It returns the status number of a request.
- statusText - It returns the details of status.
What are the important methods of XMLHttpRequest?
- abort() - It is used to cancel the current request.
- getAllResponseHeaders() - It returns the header details.
- getResponseHeader() - It returns the specific header details.
- open() - It is used to open the request.
- send() - It is used to send the request.
- setRequestHeader() - It adds request header.
What are the types of open() method used for XMLHttpRequest?
- open(method, URL) - It opens the request specifying get or post method and URL.
- open(method, URL, async) - It is same as above but specifies asynchronous or not.
- open(method, URL, async, username, password) - It is same as above but specifies the username and password.
What are the types of send() method used for XMLHttpRequest?
- send() - It sends get request
- send(string) - It sends post request.
What are the tools for debugging AJAX applications?
There are several tools for debugging AJAX applications.
- Firebug for Mozilla Firefox
- Fiddler for IE (Internet Explorer)
- JavaScript HTML Debugger
- MyEclipse AJAX Tools
- Script Debugger
What are the different ready states of a request in AJAX?
There are 5 ready states of a request in AJAX.
- 0 means UNOPENED
- 1 means OPENED
- 2 means HEADERS_RECEIVED
- 3 means LOADING
- 4 means DONE
What are the common AJAX frameworks?
- Dojo Toolkit
- YUI
- Google Web Toolkit (GWT)
- Spry
- MooTools
- Prototype
How can you test the AJAX code?
JUnit is the open source unit testing framework for client-side JavaScript. It is required to create test cases. The unit test case is a code which ensures that the program logic works as expected.
What is the difference between JavaScript and AJAX?
JavaScript is an object-based scripting language. | AJAX is a group of inter-related technologies like JavaScript, XML, HTML, CSS etc |
It requests the server and waits for the response. | It sends a request to the server and doesn't wait for the response. |
It consumes more bandwidth as it reloads the page. | It doesn't reload the page so consumes less bandwidth. |