vickkeshav Posted February 12, 2012 Share Posted February 12, 2012 <?php class My { public function disp() { echo "ehllo"; } } ?> <html> <head> <script type="text/javascript"> function displaymessage() { document.write(My.disp()); } </script> </head> <body> <form> <input type="button" value="Click me!" onclick="displaymessage()" /> </form> </body> </html> HEllo I wanted to know wheter php function can be call in js functions. Please Help. Quote Link to comment https://forums.phpfreaks.com/topic/256948-calling-a-php-function-in-javascript/ Share on other sites More sharing options...
smerny Posted February 12, 2012 Share Posted February 12, 2012 javascript is client side and cannot access server side directly. you'd have to use ajax Quote Link to comment https://forums.phpfreaks.com/topic/256948-calling-a-php-function-in-javascript/#findComment-1317267 Share on other sites More sharing options...
SergeiSS Posted February 12, 2012 Share Posted February 12, 2012 HEllo I wanted to know wheter php function can be call in js functions. The direct answer to your question is "no". But if you explain what do you like to get (I mean algorithm), then we can think together and find out a good solution for you needs. PS. I could be ajax of course, but maybe not. It's up to you, what is your aim. Quote Link to comment https://forums.phpfreaks.com/topic/256948-calling-a-php-function-in-javascript/#findComment-1317268 Share on other sites More sharing options...
vickkeshav Posted February 12, 2012 Author Share Posted February 12, 2012 Hello all, I just need to make this function work... How can I do this using ajax? please help? Quote Link to comment https://forums.phpfreaks.com/topic/256948-calling-a-php-function-in-javascript/#findComment-1317273 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.