How to execute off-site javascript that's dynamically inserted with jquery -


i'm trying dynamically change source of embedded script, having trouble.

here example of html:

<div id="inner">     <script src='http://affiliate-website/1'></script> </div> 

when page loads this, works perfectly.

but i'm trying dynamically change script's source based on user location.

when visits location b, want script source change to:

http://affiliate-website/2

so after browsing around, found snippet did wanted:

var script = document.createelement( "script" ); script.type = "text/javascript"; script.src = "http://affiliate-website/2"; $("div#inner").append(script); 

that produces following html:

<div id="inner">     <script src='http://affiliate-website/2'></script> </div> 

the problem is, script tag present, it's not executing script when put straight html. think has loading (as in when it's in html file, it's loading earlier when it's produced snippet?) don't know.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -