I want to append the html contents receiver back from the sever (server 2) to the body of the current page (which I received from sever 1). This I want to achieve while loading the page (received from server 1).( Hence I am getting the original contents from two different servers.)
I tried using
function Faulttest() {var myarray=new Array();
var urlarray=new Array();
$(document).ready(function(){
$.get({
url:"http://csce.unl.edu:8080/Anomalies/index.jsp",
data: "html",
success: function(result) {
alert(result);
$('#body').append(result) // result will be the contents received from the server
},
dataType:"text/html"
});
});
// more contents
}
The HTML contents of the page are:
<body style="font-size:62.5%;" onload="Faulttest();" >
<div id="body" >
<h1>content top </h1>
//HTML CONTENTS GOES HERE
</div>
It looks like you are trying to load a page from a different domain. Same Origin policy is going to give you trouble with that .You can’t do that !
If the file you trying to load content from is in the same domain, you can do it easily by calling the jQuery
getmethod.