下面的代碼,我有一個Ajax請求的一個片段。請求可以工作,但是當請求被處理時,頁面不會顯示任何CSS(即使我在同一個目錄中都有)。爲了測試這一點,我將請求指向了我網站上已存在的頁面。任何幫助?提前致謝。Ajax請求的工作原理,但沒有CSS
<html>
<head>
<script type="text/javascript">
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","ajaxtest.html",true);
xmlhttp.send();
}
</script>
</head>
<body>
<div id="myDiv"><h2>Let AJAX change this text</h2></div>
<button type="button" onclick="loadXMLDoc()">Change Content</button>
</body>
</html>
是'ajaxtest.html`加載任何CSS文件? – 2011-02-11 21:01:36