jQuery load() Method

## jQuery Tutorial

jQuery HOME jQuery Intro jQuery Install jQuery Syntax jQuery Selectors jQuery Events

## jQuery Effects

jQuery Hide/Show jQuery Fade jQuery Slide jQuery Animate jQuery stop() jQuery Callback jQuery Chaining

## jQuery HTML

jQuery Get jQuery Set jQuery Add jQuery Remove jQuery CSS Classes jQuery css() jQuery Dimensions

## jQuery Traversing

jQuery Traversing jQuery Ancestors jQuery Descendants jQuery Siblings jQuery Filtering

## jQuery AJAX

jQuery AJAX Intro jQuery Load jQuery Get/Post

## jQuery Misc

jQuery noConflict()

## jQuery Examples

jQuery Examples jQuery Quiz jQuery Certificate

## jQuery References

jQuery Selectors jQuery Events jQuery Effects jQuery HTML/CSS jQuery Traversing jQuery AJAX jQuery Misc jQuery Properties

# jQuery load() Method

jQuery AJAX Methods

## Example

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

$("button").click(function(){
$("#div1").load("demo_test.txt");
});
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.

## Syntax

$(selector).load(url,data,function(response,status,xhr))

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

## Your suggestion:

Your E-mail (optional):

Page address:

Description:

Close [X]

## Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

## WEB HOSTING

Best Web Hosting UK Reseller Hosting Wow! $5 SSD Hosting

## WEB BUILDING

Download XML Editor
FREE Website BUILDER FREE Website Creator

## WEB RESOURCES

Web Statistics Web Validation

## SHARE THIS PAGE