mostafatalebi Posted December 12, 2012 Share Posted December 12, 2012 Hello I have a javascript function that need to get the information from a database. How can I incorporate into my javascript a PHP script which gets the information from a database? Second Question: Is AJAX hard to learn? Link to comment https://forums.phpfreaks.com/topic/271883-using-php-in-a-javascript-function/ Share on other sites More sharing options...
MDCode Posted December 12, 2012 Share Posted December 12, 2012 1. Use jquery or ajax. 2. Not really. Link to comment https://forums.phpfreaks.com/topic/271883-using-php-in-a-javascript-function/#findComment-1398835 Share on other sites More sharing options...
mostafatalebi Posted December 12, 2012 Author Share Posted December 12, 2012 Thanks Link to comment https://forums.phpfreaks.com/topic/271883-using-php-in-a-javascript-function/#findComment-1398838 Share on other sites More sharing options...
cyberRobot Posted December 12, 2012 Share Posted December 12, 2012 Depending on what you're looking to do, you could look into grabbing the data with PHP and dumping it into a Javascript variable (or variables). Then when the page loads, that data would be available to Javascript. Link to comment https://forums.phpfreaks.com/topic/271883-using-php-in-a-javascript-function/#findComment-1398893 Share on other sites More sharing options...
Langstra Posted December 12, 2012 Share Posted December 12, 2012 Using jQuery would be the easiest what. Do an ajax post or get request to a php file. The php script gets that information for you, then it posts them back as json and the javascript reads that. Piece of cake Link to comment https://forums.phpfreaks.com/topic/271883-using-php-in-a-javascript-function/#findComment-1398942 Share on other sites More sharing options...
mostafatalebi Posted December 13, 2012 Author Share Posted December 13, 2012 Thanks, very practical information. I have a javascript function that converts English Numerals into Persian Numerals, and the number as the argument of javascript function must be retrieved from a database Link to comment https://forums.phpfreaks.com/topic/271883-using-php-in-a-javascript-function/#findComment-1399102 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.