Knowledge Management Banner

Knowledge Management Banner

AJAX - Asynchronous JavaScript and XML : Part 6

AJAX - Asynchronous JavaScript and XML
  • It is used to load data in background from server and update the part of webpage  without reloading the whole page.
  • ajax uses browser's inbuilt XMLhttprequest object to request data from server
When AJAX was developed in earlier stage it exchanged data with server in xml format and that is the reason why it was named as Asynchronous JavaScript and XML, where as now ajax can support multiple data types for exchanging data between server.

AJAX provide exchange of data in following format
  • HTML
  • JSON
  • XML
  • JAVASCRIPT
Ajax call

       $.ajax({  
         type: "GET",  
         url: "Documents/FilesAndEvidences/DeleteFilesAndEvidencesdetails",  
         data: data  
       }).done(function (dataresponse) {  
         self.LoadFilesAndEvidencesSearchPartial();  
       }).fail(function () {  
         $(".CheckingUpdates").css({ "display": "none" });  
       });  


AJAX Options

accepts: The content type sent in the request header that tells the server what kind of response it will accept in return

async: Set this options to false to perform a synchronous request

beforeSend: A pre-request callback function that can be used to modify the jqXHR object before it is sent

cache: Set this options to false to force requested pages not to be cached by the browser

complete: A function to be called when the request finishes (after success and error callbacks are executed)

contents: An object that determines how the library will parse the response

contentType: The content type of the data sent to the server

context: An object to use as the context (this) of all Ajax-related callbacks

converters: An object containing dataType-to-dataType converters

crossDomain: Set this property to true to force a cross-domain request (such as JSONP) on the same domain

data: The data to send to the server when performing the Ajax request

dataFilter: A function to be used to handle the raw response data of XMLHttpRequest

dataType: The type of data expected back from the server

error: A function to be called if the request fails

global: Whether to trigger global Ajax event handlers for this request

headers: An object of additional headers to send to the server

isLocal: Set this option to true if you want to force jQuery to recognize the current environment as “local”

jsonp: A string to override the callback function name in a JSONP request

jsonpCallback: Specifies the callback function name for a JSONP request

mimeType: A string that specifies the mime type to override the XHR mime type

password: A password to be used with XMLHttpRequest in response to an HTTP access authentication request

processData : Set this option to false if you don’t want that the data passed in to the data option (if not a string already) will be processed and transformed into a query string

statusCode: An object of numeric HTTP codes and functions to be called when the response has the corresponding code

success: A function to be called if the request succeeds

timeout: A number that specifies a timeout (in milliseconds) for the request

traditional: Set this to true if you wish to use the traditional style of param serialization

type: The type of request to make, which can be either “POST” or “GET”

url: A string containing the URL to which the request is sent

username: A username to be used with XMLHttpRequest in response to an HTTP access authentication request

xhr: A callback for creating the XMLHttpRequest object

xhrFields: An object to set on the native XHR object

No comments

Powered by Blogger.