jQuery load() on Page Load

This page demonstrates calling .load() as soon as the DOM is ready, without waiting for a user click.

Content will be requested on page load.

Load Content Automatically Top ↑

$( function () {
    $( "#result" ).load(
        "content.php"
    );
});

Show a Loading State Top ↑

$( "#result" )
    .text( "Loading..." )
    .load(
        "content.php",
        function (
            responseText,
            textStatus
        ) {
            if (
                textStatus === "error"
            ) {
                $( this ).text(
                    "Unable to load content."
                );
            }
        }
    );

← Main load() tutorial

Original Source Examples Retained for Migration Reference Top ↑

These source-page examples are retained so no learner-purpose example is silently lost. Use the modern examples above as the recommended implementation.

Original example 1

<div id=d1></div>
<script>
$(document).ready(function() {
// Jquery code here ///

$("#d1").load("load-text1.php?msg=Hello_world");

////
});
</script>

Original example 2

<?Php
$msg=$_GET['msg'];
echo "This is from load-text1.php file with Message : $msg ";
?>

Additional Original Learning Routes Top ↑






plus2net.com






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer