load()
The load()
method in jQuery is used to load data from the server and place the returned HTML into the matched elements.
load()
syntaxload( url [, data ] [, complete ] )
Parameter | Type | Description |
---|---|---|
url |
String | request url |
data |
PlainObject,String | The data sent to the server |
complete |
Function | callback function that is executed when the request completes. |
load()
exampleLoad another page's list items into an ordered list.
HTML
<b>jQuery Links:</b> <ul id="links"></ul>
jQuery
$("#links").load("/Main_Page #p-Getting-Started li");
Load the content of the file feeds.html
jQuery
$("#feeds").load("feeds.html");
POST the additional parameters to the server and a callback that is executed when the server is finished responding.
jQuery
$( "#feeds" ).load( "feeds.php", { limit: 25 }, function() { alert( "The last 25 entries in the feed have been loaded" ); });