Я делаю сайт, который будет храниться локально через локальный сервер XAMPP в музее. На одной из страниц у меня есть окно поиска. Идея состоит в том, что вы вводите это поле поиска, чтобы выполнить поиск PHP, без кнопки «поиск»... это динамично.
Все работало прекрасно, пока не переместил его с онлайн-сервера (для тестирования) на локальный хост (для правильного использования). Все, что я получаю сейчас, это слово «Отправить», но никаких функций
Вот мой javascript для превращения нажатий клавиш в поиск, а ниже моя форма.
Я использую Windows 7 и пробовал во всех браузерах. Любые идеи милые люди из Stackoverflow
Javascript:
<!--Javascript to turn keystrokes into search value-->
<script type="text/javascript">
$(document).ready(function () {
// Hide the submit button
$(":submit").hide();
// Bind an event to the keypress in order to override the form submission when pressing the enter key
$("input[name='search_term']").keypress(function (e) {
if (e.which == 13) {
// prevent the form from submitting in the normal manner (return key)
e.preventDefault();
}
});
// Bind an event to the keypress event of the text box
$("input[name='search_term']").keyup(function () {
// Get the search value
var search_value = $(this).val();
// This time we're going to grab data from a file to display
var filename = "functions/function-search.php";
// Send these values
var posting = $.post(filename, { search_term: search_value });
// Display this value in our results container
posting.done(function (data) {
$("#search_results").empty().append(data);
});
});
});
</script>
HTML-форма:
<form action="" method="post">
<input type="text" name="search_term" class="file_lable_search_box" id="search" size="10" maxlength="20" border="none" autofocus="autofocus" autocomplete="off">
<input type="submit" value="submit">
</form>