jQuery load() with Examples

jQueryWeb DevelopmentFront End Technology

The load() method in jQuery is used to load data from a server and puts the returned data into the selected element


The syntax is as follows −


Above, URL is the URL to be loaded. The data parameter is the data to send to the server, whereas the callback function runs when the load() completes.


Let us now see an example to implement the jQuery load() method 

 Live Demo

<!DOCTYPE html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<p>Demo text...</p>
<button>Load Content from server</button>


This will produce the following output −

Click the above button to load content from “new.txt” −

The content visible above is the new.txt file.

Published on 31-Dec-2019 12:33:38