我想为我的页面进行即时搜索(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,它需要在该文件夹中。 –