我想從服務器(服務器2)將html內容接收器追加到當前頁面(我從服務器1接收的)的主體中。這是我想達到在加載頁面(從服務器1接收)。(所以我從兩個不同的服務器獲取原始內容。)在使用jquery加載頁面時將內容添加到div元素
我嘗試使用
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
}
頁面的HTML內容分別是:
<body style="font-size:62.5%;" onload="Faulttest();" >
<div id="body" >
<h1>content top </h1>
//HTML CONTENTS GOES HERE
</div>
這是跨域活動。使用'dataType:jsonp',獲取更多信息[this](http://api.jquery.com/jQuery.ajax/) – diEcho 2012-07-25 13:32:18
與你的問題並不真正相關(不是說你真的問過一個問題,你只是做了一個問題一系列的語句),但沒有一個文檔就緒函數_side_ onload函數。 – nnnnnn 2012-07-25 13:35:59