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
»

jQuery’s .children() Method

Just like in CSS, it’s possible to use jQuery to select the ...

article image
»

jQuery’s .click() Method

With jQuery, it’s super easy to make something happen as a result ...

article image
»

Using jQuery’s .resize() Method

jQuery’s .resize() method is a cool way to have an event ...

article image
»

How to Use jQuery to Search and Replace HTML

Have you ever made a mistake in your code or in your text and dreaded ...

article image
»

How to Use jQuery’s .mouseover() Method

jQuery’s .mouseover() method is used to execute some jQuery ...

article image
»

How to Use jQuery’s .blur() Method

jQuery’s .blur() method isn’t exactly what it sounds like ...

article image
»

jQuery 3.0: Fix url.indexOf is Not a Function Error

jQuery 3.0 is out, and if you started working with it and plan to ...

article image
»

Set/Get/Delete Cookies with jQuery

There are a lot of plugins you can use to set, get, and delete ...

Screen Shot 2016-11-26 at 12.05.09 PM
»

3 Best jQuery Video Gallery Plugins

Do you have a lot of videos that you’d like to embed or neatly ...