Login

Username:

Password: 

Join us Now |  Forgot Password? | Forgot UserName?

jQuery

Learn step by step



jQuery-Load

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.

Syntax of .load() method

$("Specified_element").load( url, data ,callback_function_ complet )

Where

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

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

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

jQuery load() method

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


<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.1.min.js">
</script>
<script>
$(document).ready(function(){
$("#loaddata").click(function(){
$("#loadrequest").load("ajaxexample.txt");
});
});
</script>
</head>
<body>
<div id="loadrequest"></div>
<button id="loaddata">Load data for loadrequest Div</button>
</body>
</html>


Related Videos