Page 1 of 1

Including javascript code in echo statement

Posted: Wed Nov 11, 2009 2:53 am
by jishcem
I would like to call a Javascript function which performs some Ajax operations. And I would like to call it in serverside using PHP echo statement. Is that possible? If not is there any options?

Any help is very much appreciated.

Thank you, Ajeesh

Re: Including javascript code in echo statement

Posted: Wed Nov 11, 2009 3:24 am
by N1gel
The following will include a Javascript file and then you can just call the functions.

Code: Select all

echo "<script type='text/javascript' src='javascript.js'></script>";
I have found it helpful to do this in the past while developing to stop the file from being Cached

Code: Select all

echo "<script type='text/javascript' src='javascript.js?".Date("d/m/Y H:i:s")."'></script>";