快速問題,爲什麼這不起作用?使用javascript顯示內容
if (xmlhttp.responseText)
{
location.href = "result.php"
document.getElementById('page-result').innerHTML = xmlhttp.responseText;
}
我想要做的是把搜索結果放在另一頁的div上。
快速問題,爲什麼這不起作用?使用javascript顯示內容
if (xmlhttp.responseText)
{
location.href = "result.php"
document.getElementById('page-result').innerHTML = xmlhttp.responseText;
}
我想要做的是把搜索結果放在另一頁的div上。
重定向到在查詢字符串類似的消息傳遞你的下一個頁面...
if (xmlhttp.responseText)
{
location.href = "result.php?responseText=" + encodeURIComponent(xmlhttp.responseText);
}
在result.php,輸出參數「responseText的」不管你想要的內容。
ex。在php中:<?php echo $_GET["responseText"]; ?>
每個HTML頁面是獨立的;瀏覽器從每頁上的乾淨頁面開始,所以你不能像這樣操縱上一頁中的下一頁的DOM。您必須使用GET或POST(或Cookie或會話或...)將信息傳遞到下一頁,並在那裏單獨處理信息。
這不是jQuery。 – JJJ 2012-07-23 14:25:40
Juhana說,這不是jQuery。這是標準的JavaScript。如果你想要jQuery ajax:http://api.jquery.com/jQuery.ajax/ – Drakkainen 2012-07-23 14:27:53