admin管理员组文章数量:1189837
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>
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>
Share
Improve this question
asked Oct 22, 2017 at 7:47
PrashantPrashant
1431 gold badge1 silver badge7 bronze badges
2
- possible duplicate of: stackoverflow.com/questions/23258088/… – Davide Alberani Commented Oct 22, 2017 at 8:13
- Another way: https://stackoverflow.com/questions/4236040/example-of-how-to-use-fastcgi-finish-request – John Dorner Commented Jul 9, 2019 at 21:19
2 Answers
Reset to default 16PHP 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
本文标签: javascriptHow to execute php code after html page loadStack Overflow
版权声明:本文标题:javascript - How to execute php code after html page load - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738420366a2085827.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论