jQuery AJAX Functions

  • Previous page
  • Next page

jQuery has a rich library of functions (methods) for AJAX development.

jQuery AJAX Example

Click the button below to change this text through AJAX

Try it yourself

The above example is taken from our AJAX TutorialHowever, it has been modified using jQuery.

What is AJAX?

AJAX = Asynchronous JavaScript and XML.

AJAX is a technology for creating fast dynamic web pages.

AJAX allows web pages to be updated asynchronously by exchanging a small amount of data with the server in the background. This means that it is possible to update a part of the web page without reloading the entire page.

You can find more information in our AJAX Tutorial Learn more about AJAX here.

AJAX and jQuery

jQuery provides a rich library of functions (methods) for AJAX development.

Through jQuery AJAX, you can request TXT, HTML, XML, or JSON from a remote server using HTTP Get and HTTP Post.

And you can directly load remote data into the selected HTML elements on the web page!

Less code, more done

jQuery's load function is a simple (but powerful) AJAX function. Its syntax is as follows:

$(selector).load(url,data,callback)

Please use selector to define the HTML elements to be changed, using url Parametersto specify the web address of the data.

Try it yourself

Parameters. You only need to use it when you want to send data to the server. data Parameters. You only need to use it when you need to trigger a function after execution. callback Parameters.

Low Level AJAX

$.ajax(options) is the syntax of low-level AJAX functions.

$.ajax provides more functionality than higher-level functions, but it is also more difficult to use.

option The parameter settings are name|value pairs, defining URL data, password, data type, filter, character set, timeout, and error function.

Try it yourself

jQuery AJAX request

Request Description
$(selector).load(url,data,callback) Load remote data into the selected element
$.ajax(options) Load remote data into the XMLHttpRequest object
$.get(url,data,callback,type) Use HTTP GET to load remote data
$.post(url,data,callback,type) Use HTTP POST to load remote data
$.getJSON(url,data,callback) Use HTTP GET to load remote JSON data
$.getScript(url,callback) Load and execute a remote JavaScript file

(url) The URL (address) of the data to be loaded

(data) The key/value object of the data sent to the server

(callback) The function executed when the data is loaded

(type) The type of data returned (html, xml, json, jasonp, script, text)

(options) All key/value options for a complete AJAX request

Reference Manual

For more information about jQuery AJAX functions, please visit our jQuery AJAX Reference Manual.

  • Previous page
  • Next page