javascript - jquery .load() does not load external JS -


i loading external content div element using jquery.load() without selector. if content loaded has embedded js, js works expected. however, if content includes script tag src=path-to-js-code js-code not loaded.

am correct in observation , if there solution other embedding js in loaded content?

edit :
few clarifications , observations:

to load content using

$("#divid").load("path/to/content.php", callbackfunction(response, status, xhr) {     error checking , post processing code }); 

changing load code to:

$.get("path/to/content.php", callbackfunction(response, status, xhr) {     error checking     $("#divid").html(response);     post processing }); 

does not seem change behavior (more on behavior below)

i have not tried parsing response retreive script src , using getscript().

now more on behavior...

using firefox, seems external js loaded if has been 2 min last load. not see attempt in firebug unless refresh 2m after last load of external js. (weird). when making js code changes , hitting refresh, not loading new code , original question.

so withdraw question in light of clarified behavior (2m caching?).

thanks.

both .load() , .html() jquery methods utilise .innerhtml property. won't execute scripts added <script> tag. use regular ajax call e.g. .get() in callback use .append() add html string , scripts run once it's parsed e.g.

$.get("path/to/content.php", function(response, status, xhr) {     // error checking     $("#divid").append(response); // <script> tags in response string execute     // post processing }); 

thing need make sure you're running trusted code if it's added .append()


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -