X

LATEST #JQUERY NEWS

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:

$(".main").load("/demos/div-text.html");

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.

Recently Published

article image
»

Top 5 Best JavaScript Template Engines

Template engines help in the decoupling of HTML and JavaScript code ...

article image
»

3 jQuery/JavaScript Plugins for Push Notifications

Push notifications started from the mobile business but this ...

article image
»

Create Smooth Animation Using jQuery’s “stop()”

Making Quick Work jQuery’s animate() method is a quick way to ...

article image
»

Check all checkboxes in HTML table using jQuery

HTML tables are a very handy and useful element. They can adapt to ...

article image
»

Changing images in a loop on hover using jQuery

Why use this Function? Changing images in a loop on mouse over is a ...

article image
»

How to Dynamically Trim Text Using jQuery

This easy beginners jQuery tutorial demonstrates how you can use ...

article image
»

jQuery Snippets: Getting the Current Year

Here’s a fun, simple, and incredibly useful jQuery that you can ...

article image
»

jQuery Snippets: How to Conditionally Enable Submit

One easy way to prevent users from submitting an empty form in a ...

article image
»

How to Use Google Analytics with jQuery Mobile

jQuery Mobile is an HTML5 based web-page framework that’s ...