This page demonstrates calling .load() as soon as the DOM is ready, without waiting for a user click.
$( function () {
$( "#result" ).load(
"content.php"
);
});
$( "#result" )
.text( "Loading..." )
.load(
"content.php",
function (
responseText,
textStatus
) {
if (
textStatus === "error"
) {
$( this ).text(
"Unable to load content."
);
}
}
);
<div id=d1></div>
<script>
$(document).ready(function() {
// Jquery code here ///
$("#d1").load("load-text1.php?msg=Hello_world");
////
});
</script><?Php
$msg=$_GET['msg'];
echo "This is from load-text1.php file with Message : $msg ";
?>
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.