How to use jQuery AJAX .load() method with examples

What is the jQuery .load() method?

The load() method of jQuery ‘loads’ data from specified source / server and places the returned data into specified element e.g. loading data in <p> or <div> or other elements of DOM.

How to use the $.load() method

This is how you may use the AJAX load method:

$(“Specified_element”).load( url, data ,callback_function_ complete )


URL:  is a string specifying the server to which request is sent. This is required parameter.

data: Data to send to the server along with HTTP request. For example, the data to be used to query userid/password from the database server.  This is an optional parameter.

callback function: Optional parameter. After a request is completed, this function will execute if given.

jQuery load() method example

The jQuery load() method is very simple to use.  Below example shows how text in Div shown after the button is clicked, loaded from the ajaxexample.txt file. Create and place the ajaxexample.txt file to the same directory where the load() method is used with any text example data.

jQuery load

Experience this example online

See Also jQuery Get() method | jQuery post method

Was this article helpful?

Related Articles

Leave A Comment?