Reputation: 9305
I'm trying to add a js function dynamically so I read about $.getScript()
. Correct me if I'm wrong, but it seems $.getScript()
will just call a .js file that's already there in the public folder and will just sort of "load it" and make it available, but the js file itself being called is just a static js. What I'm trying to do is call a dynamic js script and the content of this js script changes considerably, so it has to come from the server.
$.getScript()
alone, or is it? So can $.getScript()
help with this or a combo of $.getScript()
and .ajax?
Upvotes: 1
Views: 1501
Reputation: 4412
Pekka's comment is correct - jquery doesn't care what the extension of the file is.
$.getScript("dynamicScript.php") will work just fine so long as that file outputs valid script (no script tags needed)
Upvotes: 3