test1.html file:
<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>
test.html :
<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>
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 that page.
The Above code snippet doesnt suffice the requirement. Please let me know what i am doing wrong in the code snippet.