Home >>jQuery Tutorial >jQuery load() Method
jQuery load() method in jQuery is used to loads data from a server and place the returned data into the selected element.
Syntax:$(selector).load(url,data,function(response,status,xhr))
Parameter | Description |
---|---|
url | It is a Required parameter and used to Specifies the URL you wish to load |
data | It is an Optional parameter and used to specifies data to send to the server along with the request |
function(response,status,xhr) | It is an Optional parameter and used to Specifies a callback function to run when the load() method is completed. Additional parameters:
|
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".btn1").click(function(){
$("#div1").load("demo_test.txt");
});
});
</script>
</head>
<body>
<div id="div1"><h2>Change This Text</h2></div>
<button class="btn1">Click me to Get External Content</button>
</body>
</html>