Why do you need JavaScriptResult as a response?
Doesn’t it break the pattern of clean separation of concerns? Can you suggest me some cases where this will be useful?
views:
997answers:
1The sole purpose of JavaScriptResult is to set the ContentType to application/x-javascript.
You might want to use this if you have an action which returns a .JS file to the browser. For example, you could write an action which concatenates all of your JavaScript files together, so that you could return them in one request instead of many. You might also want to generate JavaScript from a template.
I have seen some blog posts implying that JavaScriptResult will cause the returned file to be executed within the context of the current page. This impression apparently comes from the release notes. But I can't see any mechanism by which that would actually happen in the source code. In other words, in order to get this behavior, you would have to write code within the page causing it to happen. Simply using JavaScriptResult will not have this effect. As far as I can tell, it is simply serving up a js file.