tags:

views:

25

answers:

2

I have an html page that makes an ajax call to a jsp page that has a javascript function. It looks like the JS function is not getting executed.

Sorry I tried to search for an answer but couldn't find any.

Thanks in advance.

A: 

If your data is javascript text then in response you must dynamicly create sctript tag and put text into it.

var head= document.getElementsByTagName('head')[0];
var script= document.createElement('script');
script.type= 'text/javascript';
script.innerHTML = yourResponseScript;
head.appendChild(script);
jcubic
A: 

Even if the ajax request returned javascript, injecting that into existing html won't execute the javascript.

letronje