<button type="button" class="btn btn-info"
onclick=$("#d").load("load-text.php");>Load Page</button>
<div id='d'></div>
Inside load-text.php file we have only one line of text
<i>This message is from load-text.php file</i>
<button type="button" class="btn btn-info" id=b1>Load Page</button>
<div id='d1' ></div>
<script>
$(document).ready(function() {
$("#b1").click(function(){
$("#d1").load("load-text1.php?msg=Hello_world");
})
})
</script>
var msg=encodeURIComponent("Hello World");
$("#d1").load("load-text1.php?msg="+ msg);
Our backend file load-text1.php code is here
<?Php
$msg=$_GET['msg'];
echo "This is from load-text1.php file with Message : $msg ";
?>
First Name<br><input type=text name=t1 id=t1>
Last Name<br><input type=text name=t2 id=t2>
<br><button type="button" class="btn btn-info" id=b2>Load Page</button>
<div id='d2' ></div>
<script>
$(document).ready(function() {
$("#b2").click(function(){
str1=$('#t1').val();
str2=$('#t2').val();
$("#d2").load("load-text2.php", {'t1':str1,'t2':str2});
})
})
</script>
Our Backend script load-text2.php file code is here
<?Php
$t1=$_POST['t1'];
$t2=$_POST['t2'];
echo "Welcome $t1 $t2";
?>
<button type="button" class="btn btn-info" id=b3>Load Page</button>
<div id='d3' ></div>
<script>
$(document).ready(function() {
$("#b3").click(function(){
$("#d3").load("load-text.php",function(){
alert ( ' Content of load-text.php is loaded');
})
})
})
</script>
Using callback function we can display messages to the user about the backend process. Once the user click a button the process starts, then we will show a message telling user to wait. At the backed script we will create a delay of 5 seconds. After the delay period we will show process complete message to user by using the callback function.
Here is the JQuery Script.
<script>
$(document).ready(function() {
/////
$("#b1").click(function(){
$('#msg').html('Wait .. ');
$('#msg').show();
$("#d1").load("load-delay-msgck.php", function() {
$('#msg').html('Done .. ');
setTimeout(function() { $("#msg").fadeOut('slow'); }, 4000);
});
})
////////////////
})
</script>
DEMO of messages like wait .. done ..etc. with load() function
$('#d2').on('click', ".my_class", function () { // your script here //var b_card_id=this.id; // read the id of clicked class })Here my_class is class used in loaded page which gets loaded after an event. #d2 is the id of the Div to display content which is loaded.
my_load_function=function my_function(){
$('#display_body').load("category-display.php");;
}
///calling the function ///
my_load_function();
You can read more on how to use an user defined function here. $('#display_body').on('click', ".edit_class", function () {
// Your code here
})
#display_body is the element to where part of the page is loaded after DOM is created. 21-04-2020 | |
Thank you so much. This solution really worked for me , i have been struggling to to post table row id to external php page by row click in jquery |
Most Popular JQuery Scripts | |
1 | Two dependant list boxes |
2 | Calendar with Date Selection |
3 | Data change by Slider |
4 | Show & Hide element |