Use of Jquery Load. Explain with an Example.

Posted by

The jQuery load() method is a simple, but powerful AJAX method.

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

Syntax:

$(selector).load(URL, data, callback);

Parameters

  • URL: It is used to specify the URL which need to load.
  • data: It is used to specify a set of query key/value pairs to send along with the request.
  • callback: It is the optional parameter which is the name of a function to be executed after the load() method is call.

Return Value: This method returns the requested data from server with the specified URL.

Example:

Here is the content of our example file: “demo.txt”:

<p>This is R.k. Jha </p>