Now a days lots of website are using jQuery Ajax to retrieval the data without refreshing the webpage, previously we have to code for XMLHttpRequest or ActiveXObject object for different browsers.
Now jQuery changed with their library which will support lots ajax method like $.ajax, $.getJson, $.post and much more. Today we are going to focus on $.ajax method.
How Ajax works
1) create XMLHttpRequest object and send httprequest to server.
2) process the httprequest, send the response to client browser.
3) getting the data using javascript and display in client browser.
<!-- include jQuery library --> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script language="javascript"> // global varaible will use to check the ajax call var ajaxObject = null; // ajaxcall function will handle ajax call function ajaxCall() { // static parameter send the value to server var query = 'yes'; // checking ajaxObject varaible null or not, // If the ajaxObject is not null then it will abort the current ajax call // and reinitialize the ajaxcall assign the ajaxObject null if(ajaxObject!=null) { ajaxObject.abort(); $("#spnStatus").html("ajax abort and reinitialized"); ajaxObject = null; }