Using the jQuery .load() Method

jQuery's .load() method is used to load data from a server (from a directory within your domain) and then place the loaded data into your selected element. The load method syntax looks a lot like many of the other commonly used jQuery methods, except that it can take a lot more parameters than your standard jQuery method. Here's a basic example of how it works:


The code above will load the contents of the div-text.html file and place it into the .main div. The basic syntax and concept of the method is fairly simple and straightforward, but it's also a good idea to acquaint yourself with the parameters that the method will take. The official syntax looks like this:

$("selector").load("url", data, function(responseText, textStatus, xhr));

In the example above, url obviously represents the url of the data you're trying to load. Data represents any data to send to the server along with your request. Function represents any callback function you'd like to execute, where response contains the result data from your request, status contains the status of your request (whether it's successful or not), and xhr represents the XMLHttpRequest object.

Responsive Menu
Add more content here...