How would one dynamically load Javascript that has been parsed as PHP?
Posted
by
beatsforthemind
on Stack Overflow
See other posts from Stack Overflow
or by beatsforthemind
Published on 2012-07-10T03:05:42Z
Indexed on
2012/07/10
3:15 UTC
Read the original article
Hit count: 86
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.
© Stack Overflow or respective owner