como carregar a resposta Jquery (página HTML com tags de script) no DOM
arquivo test1.html:
<code><html> <head> <script src="jquery-1.7.2.js"> </script> <script> function loadfn(){ $.get('test.html',function(data){ alert($(data).text()); //$('body div#returnData').html(data); $.each(data, function(i, node) { alert(i); if (node.tagName == "SCRIPT") { eval(node.innerHTML); } else { $(node).appendTo($('#returnData')); } }); }); test1(); test2(); } </script> </head> <body> <div id="returnData" > </div> <input type="button" value="Click" onclick=loadfn()> </body> </html> </code>
test.html:
<code><html> <head> <script src="/jquery-ui-timepicker-addon.js"> </script> </head> <script> function test1(){ alert('test1 function'); } </script> <script> function test2(){ alert('test2 function'); } </script> <body> <div id="testdiv"> Text field : <input type="text" value="Test Value"/> </div> </body> </html> </code>
Na verdade eu tenho o requisito que eu tenho que carregar a página test.html em test1.html e, em seguida, executar as funções de script que estão lá nessa página.
O trecho de código acima não é suficiente para o requisito. Por favor, deixe-me saber o que estou fazendo de errado no trecho de código.