javascript - Append script to page using jquery -


i receive on data (after ajax call) 2 script tags, data this:

var scripts = $(data).filter('script');     

now want append content of 2 script tags div. how can this?

for(var i=0; < scripts.length; i++) {     $('#mydiv').append(scripts[i]); } 

the above approach doesn't append anything.

i can't reconstruct scripts in js (i've seen approach in other posts) because scripts contain loads of elements , logic.

try this:

function codegenerate(code){     var js= document.createelement('script');     js.text= code;     document.body.appendchild(js); } 

Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -