Search code examples
phpjavascriptserver-side

Use Server php values in javascript


This question is because I have some values in a database table that works as parameters, so the approach I think to use them in javascript without using inline scripts was call a parameters.php that returns all the values and stores them in javascript global variables to use them. I just want to know if this is correct or if there is better way how to do this.


Solution

  • That may very well work, but I think it's just as easy to generate inline javascript in the page itself. I assume the parameters may change on each request, so by putting them in the page itself, you save a request for each page view.