Thursday, April 23, 2009

Execute Javascript from AJAX request

Hi, just get this simple n usefully javascript function that allow javascript to be execute under innerHTML from AJAX request. original source: http://www.coderanch.com/t/117983/HTML-JavaScript/Execute-JavaScript-function-present-HTML code: function setAndExecute(divId, innerHTML) { var div = document.getElementById(divId); div.innerHTML = innerHTML; var x = div.getElementsByTagName("script"); for(var i=0;i { eval(x[i].text); } }

No comments: