after full html page load want to execute some php api's & script and display response
<html>
<body>
content
<?php
//some php script execute after full page load
?>
</body>
</html>
You can't, unless you instruct Apache to treat . html files as PHP.
PHP is a server-side programming language. It gets executed when you request a page. So you cannot execute it after the page has been loaded. If you need to check if something has loaded on the client side, you'll have to use a client-side programming language like JavaScript.
That way you can make a request to a PHP file (which will be executed) and get process everything that is returned by the file.
You can do this using JavaScript or jQuery (a JavaScript library):
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
// Check if the page has loaded completely
$(document).ready( function() {
$('#some_id').load('php-file.php');
});
</script>
To do so you could make use of the Ajax calls after the page is rendered ,
$(window).load(function(){ /*This allows to execute your code after the page is rendered fully */
$.get("<path to php file>", function(data){
/* you can then process the ajax response as needed */
});
})
You can this (Javascript that executes after page load) ,to be helpful to load your script after page load
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With