Page 1 of 1

How to execute PHP from Javavscript

Posted: Tue Feb 23, 2010 12:34 am
by Neo
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);';
?>