How To Send Additional Javascript Code To Client From Nodejs Server After Page Load
When a popup shows up on my website, I want the div in that popup rendered one of many different ways depending on what a certain chosen setting is. Ideally, I'd want a button pre
Solution 1:
I would use eval()
to solve your problem.
Using Ajax on client :
$.ajax({
url:'MyServer/code.json',
success : function(data, code) {
eval(data.code);
}
});
MyServer/code.json
{
"code":"alert('Code from server executed.'); $('body').css({ 'background-color': '#000'});"
}
This is a simple example with JSON and this is not secure at all. Be carefull using eval()
.
Post a Comment for "How To Send Additional Javascript Code To Client From Nodejs Server After Page Load"