posted 15 years ago
I am using a rest service to return an html string to a calling application; when I directly place a javascript function (using script tag) within the html that is returned the browser is able to interpret what it receives and the function can be executed. However, when I only include a reference to a javascript function (ie. using a script tag to include a .js file) rather than the function itself then the function is not included in the returned html (just the literal reference to the .js file) and it won't execute on the browser.
Inasmuch as web services aren't really intended to return markup to browsers this doesn't surprise me, but assuming I have a good reason for wanting to do this is there a way to force the REST servlet to interpret/include javascript the same way, say, a jsp page would if it received a get request? Basically I want it to pull in the javascript function I am referencing and include it in the string that it returns.
thanks