Without seeing the head of your site and the way you are referencing Javascript files/libraries, I'd guess that it could be a referencing problem. Moving from online to a local instance you may need to adjust the way you are referencing Javascript files. I'd also suggest not using XAMPP for a production server, locally or otherwise, as it's main purpose is for development environments.
Site with a 'hidden' submit button for Search not working on local server
Question
I'm making a site that will be stored locally via an XAMPP local server in a museum. On one of the pages I have a search box. The idea is that you type into this search box to perform a PHP search, with no need for a 'search' button.. it's dynamic.
All has worked beautifully until moving it from an online server (for testing) to a local host (for proper use). All I get now is the word 'Submit' but no functionality
Here is my javascript for turning the keystrokes into a search, and below that is my form.
I'm using Windows 7 and have tried on all browsers. Any ideas lovely people of 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:
<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>
No correct solution
OTHER TIPS
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow