` element: ``` $("button").click(function(){ $("#div1").load("demo_test.txt"); }); ```"> ` element: ``` $("button").click(function(){ $("#div1").load("demo_test.txt"); }); ```" />
Easy Tutorial
❮ Misc Jquery Speed Misc Callbacks Locked ❯

jQuery load() Method

jQuery AJAX Methods

Example

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

$("button").click(function(){
    $("#div1").load("demo_test.txt");
});

Definition and Usage

The load() method loads data from the server and places the returned data into the specified element.

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


Syntax

Parameter Description
url Required. Specifies the URL you need to load.
data Optional. Specifies data to be sent to the server along with the request.
function(response,status,xhr) Optional. Specifies a callback function to run when the load() method is completed. <br> <br> Additional parameters: <br> response - Contains the result data from the request <br> <br> status - Contains the status of the request ("success", "notmodified", "error", "timeout", "parsererror") <br> <br> xhr - Contains the XMLHttpRequest object

More Examples

Generate an AJAX request and send data through that request (explained in the AJAX Tutorial).

Generate an AJAX request and use a callback function

Generate an AJAX request with an error


jQuery AJAX Methods

❮ Misc Jquery Speed Misc Callbacks Locked ❯