Online Shopping : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to
Did You Find This Entry Useful?

136 of 206 people (66%) answered Yes
Recently 7 of 10 people (70%) answered Yes


Can I call a PHP function from Javascript?

Mar 15th, 2008 18:18
ha mo, logu logu, Louis Brown, Chris Pelling,

Javascript is client side, so it runs on the browser, 
PHP is server side, so simply put, produces plain html to the browser, 
not its functions. So the short answer is no!.
The only theoretical way that this could be done (as far as i know),
is if your javascript spawns a pop up, which could be used to run PHP 
code and return the result you are after.
Then use the Javascript "window.opener.   " commands to assign the 
result from the popup code back to the original Javascript function.
It would work, but it seems a bit of a hash.