SHARE

Insert PHP file using JQuery after page loading

Using JQuery you can control your page loading . For this you need to hold the file and insert it in specific area of web page after page loading .

Suppose you want that a specific

Example Source Code

<div id="insert-file"></div>
<script type="text/javascript">
$(document).ready(function(){
$('#insert-file').load('http://example/folder/custom.php');
});
</script>
</body>

Working

In this example load() function is used to load files . load() is a build in function of jQuery .

Steps

  • code place the <div> tag with custom class attribute where you want to insert php file .  In this example i create
<div id="insert-file"></div>
  • Create a jquery at the end of the page just before </body> tag . Use document.ready() so your script run after page load .
  • Get the specific <div> by id  in this example insert-file is div id and use the load() function to get the custom.php file and insert in the div .

Note: Don’t forget to link jquery file at head section of web page before run the code .