Reputation: 347
I get following solution to execute php script every 1 min but it does not work.can you find error or any new solution?
<?php
while (true)
{
echo "hi";
sleep(60));
}
?>
Upvotes: 1
Views: 1792
Reputation: 390
You can do this with AJAX Jquery AJAX Docs : http://api.jquery.com/jquery.ajax/
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
<title>asd</title>
</head>
<script type="text/javascript">
function theAjaxCall(){
$.ajax({
url: 'your_php_file.php',// set your config
data: {action: 'test'},
type: 'post',
success: function(output) {
$("body").append(output);
}
});
}
$(document).ready(function(){
setInterval(theAjaxCall, 60000);//every 1 min
});
</script>
<body>
</body>
</html>
Upvotes: 1