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
»

Add Keyboard Shortcut to Anchor Tag Using jQuery

Making a user friendly website can be quite a challenging task. There ...

Screen Shot 2017-04-23 at 10.15.41 AM
»

How to Use jQuery to Create a Sticky Navigation on Scroll

Creating “sticky” elements is something that can often be ...

article image
»

How to Use jQuery’s Keystroke Methods

jQuery has a few built-in keystroke methods that are all triggered by ...

article image
»

How to Change iFrame Styling Using jQuery

If you’ve ever had the displeasure of working with iFrames, ...

article image
»

How to Use jQuery to Create Blinking Text

Blinking text is one of those cool features that you never actively ...

article image
»

Convert Images to Black and White using jQuery

Converting an image to black and white is no longer a manual event. ...

article image
»

How to Disable Right-Click Menu Using jQuery

There can be dozens of reasons why you may want to disable right ...

article image
»

How to Optimize jQuery Code for Better Performance

jQuery is the most popular client side library, in fact almost every ...

article image
»

Using Head.js to Load All Your JavaScript

In the past few years, client side frameworks/libraries have become ...