Stats

2585 Contributors: 26
2017-07-10
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook

Ajax

Download jquery eBook

Syntax

  • var jqXHR = $.ajax( url [,settings] )
  • var jqXHR = $.ajax( [settings] )
  • jqXHR.done(function( data, textStatus, jqXHR ) {});
  • jqXHR.fail(function( jqXHR, textStatus, errorThrown ) {});
  • jqXHR.always(function( jqXHR ) {});

Parameters

ParameterDetails
urlSpecifies the URL to which the request will be sent
settingsan object containing numerous values that affect the behavior of the request
typeThe HTTP method to be used for the request
dataData to be sent by the request
successA callback function to be called if the request succeeds
errorA callback to handle error
statusCodeAn object of numeric HTTP codes and functions to be called when the response has the corresponding code
dataTypeThe type of data that you're expecting back from the server
contentTypeContent type of the data to sent to the server. Default is "application/x-www-form-urlencoded; charset=UTF-8"
contextSpecifies the context to be used inside callbacks, usually this which refers to the current target.

Remarks

AJAX stands for Asynchronous JavaScript and XML. AJAX allows a webpage to perform an asynchronous HTTP (AJAX) request to the server and receive a response, without needing to reload the entire page.

Related Examples