How would one dynamically load Javascript that has been parsed as PHP?
- by beatsforthemind
I am looking to dynamically load javascript that has been parsed as PHP so that I will be able to pass PHP variables to javascript, and then load this file into the primary PHP document. I have a document called myscript.js.php that includes the javascript and PHP. I attempted to load it into the primary document using jQuery's getScript like this:
$.getScript("myscript.js.php", function() {
alert('loaded script.');
});
This attempt failed - I am assuming because of the .php extension on the file. Is there anyway to dynamically load javascript that includes PHP? I have a few session variables that I am looking to pass through javascript that will be updated frequently, creating a need for the javascript to be reloaded.