I’ve an html file with php extension (index.php) and i use a mix of javascript and php code.
The problem is that i’m unable to launch a php function from JS..
this don’t work
[code=php]
<?php
function updateVideo(){
//some code
}?>
<script>
function aggiornaVideo(){
<?php updateVideo(); ?>
}
</script>
Yes, i know that PHP is a server side language while JS a client-side, but for what reason if i attempt to access to php variables along the document it’s possibile such they are stored in memory while the same thing isn’t possible with function?
For exemple, this code normally retrieve me a variable from php
[code=php]
<?php
$page=4
//some code
} ?>
<script>
function aggiornaVideo()
{
var pro='<?php echo $page; ?>’
alert(pro)
}
</script>