How to execute PHP from Javavscript

Post Reply
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

How to execute PHP from Javavscript

Post by Neo » Tue Feb 23, 2010 12:34 am

In the page with the JS you start an interval, and then point the src of another JS to your PHP page.

Code: Select all

<script type="text/javascript">
var process = function()
{
    do_stuff();
}
var processing = setInterval(process, 1000);
</script>
<script type="text/javascript" src="script.php"></script>
Then in "script.php" you print some javascript that will clear the interval at the end.

Code: Select all

<?php
do_stuff_in_php();
echo 'clearInterval(processing);';
?>
Post Reply

Return to “PHP & MySQL”