Hello,
Can I put php coding in a .js file? I understand that php is server-side and js is client-side. I want to call a php function and add data to the .js file, dynamically ....
Using php in js file
Page 1 of 12 Replies - 3176 Views - Last Post: 06 April 2009 - 03:07 PM
Replies To: Using php in js file
#2
Re: Using php in js file
Posted 06 April 2009 - 07:53 AM
You can't put them in the same file, but if I understand what you are asking, it is indeed possible using an AJAX call.
This tutorial:
http://www.dreaminco...wtopic44808.htm
should get you started with making it work.
This tutorial:
http://www.dreaminco...wtopic44808.htm
should get you started with making it work.
#3
Re: Using php in js file
Posted 06 April 2009 - 03:07 PM
Your server should have settings for what file extensions to parse for PHP, maybe if you add ".js" to the list you will get the desired result?
Remember, you can always include JS in your html files.
EDIT:
This is assuming of course that you want to use PHP to generate JS code. If you want to call JS from PHP, go with the above suggestion.
Remember, you can always include JS in your html files.
EDIT:
This is assuming of course that you want to use PHP to generate JS code. If you want to call JS from PHP, go with the above suggestion.
This post has been edited by c0mrade: 06 April 2009 - 03:09 PM
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|