I am new to php, Please give me a help if anyone know how to execute an external JavaScript function from a function in another PHP file. (or using Ajax).
In my code (see the comment):
In index.php->
<script type="text/javascript">
function OnUnityReady()
{
u.getUnity().SendMessage("test", "SubmitInputValue", "name");
}
</script>
In chatApp.php ->
<?php
class pfcCommand
{
function write($chan, $nick, $cmd, $param)
{
$data .= $nick."\t";
$data .= $cmd."\t";
$data .= $param;
.
.
$this->setMeta("channelid-to-msg", $this->encode($chan), $msgid, $data);
//FROM HERE, I NEED TO EXECUTE OnUnityReady() FUNCTION in index.html
//IN EVERY TIME WHEN EXECUTE THIS write FUNCTION
return $msgid;
}
}
?>
You cannot execute a javascript function from within a php script. Especially since javascript is parsed by your browser, using file_get_contents() or cURL wouldn't work. Find a way to replicate the JavaScript function in PHP :/