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> Link to comment https://forums.phpfreaks.com/topic/215430-calling-php-function-inside-javascript-function/ 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. Link to comment https://forums.phpfreaks.com/topic/215430-calling-php-function-inside-javascript-function/#findComment-1120260 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 Link to comment https://forums.phpfreaks.com/topic/215430-calling-php-function-inside-javascript-function/#findComment-1123161 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.