How Does Dojo/request Handle Html/javascript Response?
Actually, we know dojo/request have a property 'handleAs' that can handle about: text json javascript xml But how about if the response is a html fragment with javascript embedde
Solution 1:
As I explained you in your other questions, JavaScript is never automatically being executed when using AJAX requests (like dojo/request/xhr
) out of security matters.
If you want to execute JavaScript code that's dynamically loaded, you will have to use the eval()
function to parse it. However, I also told you already that the Dojo toolkit already has a module to handle XHR requests and execute scripts on it by using a dojox/layout/ContentPane
and the executeScripts
property.
However, the use of eval()
and loading scripts from an AJAX request is considered a bad practice and means your application design probably could be improved. Move the JavaScript onto the parent page (in stead of the fragments) and then you have no problems.
Post a Comment for "How Does Dojo/request Handle Html/javascript Response?"