0
我有加載引號的頁面。它有一個搜索表單,如果用戶鍵入搜索關鍵字,它將通過ajax加載結果。現在,如果我點擊應該使用引號加載默認頁面的鏈接,而不是搜索結果頁面,則什麼都不會發生。jQuery加載默認頁面問題
如果我在家裏/默認頁面上,點擊鏈接,它會顯示一個隨機引用,但是一旦顯示了搜索頁面,如果我點擊鏈接顯示一個隨機引用,什麼都不會發生。 Firebug顯示該功能未被執行。
jQuery代碼:
function loadQuotes() {
$("#bquote").load("quotes_in.php");
}
$("a#main").click(function() {
$(this).addClass("current");
$(".toggleDiv").slideUp(600);
loadQuotes();
});
loadQuotes(); //call it once on load
$(".bsearch").keydown(function() {
//create post data
var postData = {
"search" : $(this).val()
};
//make the call
$.ajax({
type: "POST",
url: "quotes_in.php",
data: postData, //send it along with your call
success: function(response){
setTimeout(function() {
$('#left').html(response);
$("div#smore").hide();
}, 250);
}
});
})
HTML:
<!-- Begin Left Column -->
<div id="left">
<!-- Begin Panel -->
<div class="check">
<p><input type="checkbox" value="Quote" name="quote" id="quote" checked /> <label for="quote">Quote</label></p>
<p><input type="checkbox" value="Reference" name="reference" id="reference" checked /> <label for="reference">Reference</label></p>
</div>
<!-- End Panel -->
<!-- Begin Quote -->
<blockquote id="bquote">
</blockquote>
<!-- End Quote -->
</div>
<!-- End Left Column -->
<!-- Begin Naviagtion -->
<div id="navigation">
<ul>
<li><a id="main">Another?</a></li>
<li><a id="bsearch">Search</a></li>
<li><a id="babout">About</a></li>
<li><a id="bcontact">Contact</a></li>
</ul>
</div>
<!-- End Naviagtion -->
PHP搜索:
public function formatSearch($row, $search)
{
$cQuote = $this->highlightWords(htmlspecialchars($row['cQuotes']), $search);
return "<div class=\"swrap\">"
. "<p id=\"s_quotes\"><img src=\"image/list1.png\" alt=\"b\" style=\"position:relative; top:2px;\"> " . $cQuote . " </p>"
. "<div id=\"smore\"><p id=\"s_arabic\">" . $this->h($row['cArabic']) . "</p>"
. "<p id=\"s_author\"><b>~</b> " . $this->h($row['vAuthor']) . "</p>"
. "<p id=\"s_reference\"><span class=\"source\">Source:</span> " . $this->h($row['vReference']) . "</p></div></div>"
. "<img src=\"image/sep.png\" style=\"position:relative; left: 600px;\">";
}