how to load an external html page(Html tags along with script functions) into the current page(DOM)
<p>test1.html</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;script src="jquery-1.7.2.js"&gt;
&lt;/script&gt;
&lt;script&gt;

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();
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="returnData" &gt;
&lt;/div&gt;
&lt;input type="button" value="Click" onclick=loadfn()&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>test.html :</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;script src="/jquery-ui-timepicker-addon.js"&gt;
&lt;/script&gt;
&lt;/head&gt;
&lt;script&gt;
function test1(){
alert('test1 function');
}
&lt;/script&gt;
&lt;script&gt;
function test2(){
alert('test2 function');
}
&lt;/script&gt;
&lt;body&gt;
&lt;div id="testdiv"&gt;
Text field : &lt;input type="text" value="Test Value"/&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Actually i have the requirement that i have to load the test.html page into test1.html and then run the script functions that are there in the test.html page.</p>

<p>The Above code snippet doesnt suffice the requirement. Please let me know what i am doing wrong in the code snippet.</p>
