Smudly Posted October 8, 2010 Share Posted October 8, 2010 How can I call a PHP Function inside a Javascript Function? This is what I have so far, but I don't think I'm doing it the right way. Any suggestions? <?php function phpQuery(){ $query = mysql_query("INSERT INTO mytable VALUES('','name','email')"); } ?> <script type="text/javascript"> function delayQueries() { timeoutID = window.setTimeout(doQueries, 2000); } function doQueries() { var runQuery = "<?php phpQuery(); ?>"; } </script> Quote Link to comment Share on other sites More sharing options...
ShoeLace1291 Posted October 8, 2010 Share Posted October 8, 2010 You probably want to use AJAX for this. Ajax is asynchronous javascript and XML, but you can output plain text with it as well. Very good explanations can be found at W3Schools.com. Quote Link to comment Share on other sites More sharing options...
Colton.Wagner Posted October 18, 2010 Share Posted October 18, 2010 Yeah, If you know javascript and php AJAX is not hard to learn. w3schools.com will be very helpful. Also there is a help section for AJAX if you want to post any of your problems there. Thanks, Colton Wagner Quote Link to comment 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.