Tutorials Exercises Get Certified Services Menu
Log in
Sign Up Spaces Bootcamps

jQuery load() Method

❮ jQuery AJAX Methods


Load the content of the file "demo_test.txt" into a specific <div> element:

Try it Yourself »

Definition and Usage

The load() method loads data from a server and puts the returned data into the selected element.

Note: There is also a jQuery Event method called load. Which one is called, depends on the parameters.



Parameter Description
url Required. Specifies the URL you wish to load
data Optional. Specifies data to send to the server along with the request
function(response,status,xhr) Optional. Specifies a callback function to run when the load() method is completed.

Additional parameters:
  • response - contains the result data from the request
  • status - contains the status of the request ("success", "notmodified", "error", "timeout", or "parsererror")
  • xhr - contains the XMLHttpRequest object

Try it Yourself - Examples

Make an AJAX request, and send data with the request
How to use the data parameter to send data with the AJAX request (this example uses the an example explained in our AJAX Tutorial)

Make an AJAX request and use a callback function
How to use the function parameter to work with the data result from the AJAX request.

Make an AJAX request with an error
How to use the function parameter to deal with errors in an AJAX request (using the XMLHttpRequest parameter).

❮ jQuery AJAX Methods