Tag Archives: AJAX

Top 10 AJAX Interview Questions and Answers

What is AJAX?
Full form of AJAX is Asynchronous JavaScript And XML.
AJAX facilitate web pages to be updated asynchronously by exchanging data with a web server in the background. It can update the webpage without reloading the whole page.

What are the main components that are used by AJAX?
AJAX components are :
1-A browser built-in XMLHttpRequest object
2-JavaScript and HTML DOM

What is XMLHttpRequest Object?
The XMLHttpRequest object can be used to request data from a web server without refreshing the whole page. It can send data to the server in the background and can ask and receive data in the background.

What is the request type used by XMLHttpRequest Object?
open(): It specifies the kind of request GET or POST
send(): Sends the GET request to the server
send(string): Sends the POST request to the server

Give an Example of a jQuery AJAX call.
A POST method AJAX example in jQuery:

var empId = $("ul .emp").first().attr("id");
var request = $.ajax({
url: "myajaxcall.php",
type: "POST",
data: {id : empId},
dataType: "json"

request.done(function(response) {

request.fail(function(jqXHR, ajax_status) {
alert( "Request failed: " + ajax_status );

What is the difference between xhr.status and xhr.readyState?
xhr .status: used to determine whether the request was successful or not.
xhr.readyState: the state of the request.’
xhr.readyState zero(0) means “has not yet been sent”
xhr.readyState zero(4) means “complete and response received”
The server provides the status, while the user agent provides the readyState.

Spread the love