faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

135 of 204 people (66%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

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.
http://www.tantofa.com
http://www.fantofa.com
http://www.mantofa.com
http://www.tanpola.com
http://www.tampola.com
http://www.yamot.com
http://www.mozmar.com
http://www.templatestemp.com