load() method
What is jQuery load() method()

The jQuery load() method data from a server and puts data to HTML element.

Syntax:

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

URL which we want to load(Required)

data is querystring key and value which we want to send to server(Optional)

callback method call when load method is completed(Optional)

Example of Load() method

<html>

<head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script>

$(document).ready(function(){

    $("button").click(function(){

        $("#mydiv").load("test.php");

    });

});

</script>

</head>

<body>

<div id="mydiv">When we click the test.php data will be loaded</div>

<button>Click Here</button>

</body>

</html>


Previous