我想爲我的頁面進行即時搜索(google like)。當用戶編寫食物名稱時,它必須從數據庫中搜索變量,並在有匹配時返回(我將使用php).Php代碼不會導致現在的問題,但Java是其他的東西。它顯示this錯誤,當我輸入任何letter.I嘗試了一切從頭開始像5次,每次我到達Java它開始這個錯誤。我的食物,組,BG頁是this,它是在我的主要主題文件夾裏,其他所有.php頁面文件。我不知道爲什麼它無法找到該頁面。請幫助;/ 順便說一句我正在wordpress工作。
jQuery(document).ready(function ($) {
\t $("#food_search").keyup(function(event){
\t \t var search_term =$(this).val();
\t \t $.post("/Food-Groups-BG.php",{search_term: search_term},function(data)
\t \t \t {
\t \t \t \t $("#food_search_result").html(data);
\t \t \t })
\t });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<p>Търсене на храни: <input type="text" name="food_search" id="food_search"></p>
<div id="food_search_result"></div>
功能如何確保你的'/食品組 - BG.php'是它應該是什麼?即在文檔根目錄中。 –
嗯,我讀過,如果文件在主目錄中,它必須只有/和文件名,我真的不知道如何獲取主目錄沒有聲明它..我仍然是一個新手 –
嗯,只是一個擡頭:您正在將JavaScript與Java混淆。兩種截然不同的使用情況非常不同的語言。你的web根目錄(主文件夾)通常是包含wp-admin,wp-includes和wp-content的目錄。所以,如果你想使用像/filename.php這樣的URL,它需要在該文件夾中。 –