</>
Skip to content
jQuery lessons (29/39)

jQuery — Load

Basic load()

$("#content").load("page.html");

load with Callback

$("#content").load("page.html", function(response, status, xhr) {
    if (status === "success") {
        console.log("Content loaded");
    }
});

Load with Selector

// Load only #main from page.html
$("#content").load("page.html #main");

Load with Data

$("#results").load("search.php", { query: "jQuery" });

Practical: Partial Page Updates

// Load sidebar content
$("#sidebar").load("/partials/sidebar.html");

// Load on click
$(".load-more").click(function() {
    $("#content").load("next-page.html");
    return false;
});

AJAX Loading Indicator

$("#content")
    .html("<p>Loading...</p>")
    .load("page.html", function() {
        console.log("Done");
    });

load() vs $.ajax()

Featureload()$.ajax()
MethodGET onlyAny
TargetAlways inserts HTMLFull control
ComplexitySimpleAdvanced

Mini Practice

  1. Load HTML into a div
  2. Load with a selector filter
  3. Show a loading state during load
  4. Load content on button click

Up Next

Continue with Get and Post — simplified AJAX requests.

Related Topics

Frequently Asked Questions about Load

What is Load in jQuery?

Load is a fundamental concept in jQuery. This lesson explains it step by step with clear examples, making it easy for beginners to understand.

How do I learn Load?

Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Load.

Why is Load important in jQuery?

Load is essential for jQuery development. Understanding this concept will help you write better code and solve real-world problems more effectively.