javascript - Dynamically adding html from external view -
i have function in javascript appending html div like:
$("#test").html("<tr><td>" + data[0].foo + "</td></tr>");
i don't want html in code, want place external file , load variable. data variable? how pass external file? how use it?
you can store code in file (let's script.js
because i'm feeling creative), , using jquery function $.getscript( "script.js")
load script page. if have name in variable, that's not problem, can use
var scriptsrc="script.js"; $.getscript(scriptsrc);
does answer question?
Comments
Post a Comment