我有我的網站上的index.html在html + CSS中,在我的index.html我有這個div ID「內容」,你把主要內容放在頁面,並且在菜單欄中有一個與page2.php相關的鏈接。當你點擊鏈接時,它會轉到page2.php,但我希望它在< div內容中顯示。 在第2頁,我有你好這是一個測試,在回聲..網站包括我的網站的頁面/頁面
我不想使用框架..我應該分割我的index.php上設計,然後在page2.php中將包括頂頁腳&?或者有另一種方式
function test() {
var xhr = XMLHttpRequest();
xhr.onreadystatechange = function(){
if(xhr.readystate==4 && xhr.status=200)
document.getElementById('content').innerHTML = xhr.responseText;
};
xhr.open("GET", "start.php", false);
xhr.send(null);
}
<a href="start.php" onclick="test(); return false;">Hjem </a> |
<div id="content" ></div>
安裝Firefox的Firebug插件。更新答案,檢查它。 – 2010-03-17 22:25:12
我想阿賈克斯對你來說太難了。所以堅持你最瞭解的東西。嘗試一些其他時間。 – 2010-03-17 22:46:55