Sometimes I use the jQuery load() function to display dynamic content inside html elements. As the description says:
load() Description: Load data from the server and place the returned HTML into the matched element.
I provided a working example that loads a simple html file with html tags and another php files that contains variables.
Here is the jQuery code:
$(document).ready(function() { $(".click-html").on('click', function() { $( ".load-html" ).load( "load.html" ); }); $(".click-php").on('click', function() { $(".load-php").load("click.php?var1=var1value&var2=var2value"); }); });
Here is the PHP code that deals with the two variables:
<?php echo $_GET["var1"]; echo "<br>"; echo $_GET["var2"]; if($_GET["var2"] == "var2value") { echo "<hr>"; } ?>