how to make an ajax search
Posted
by amir
on Stack Overflow
See other posts from Stack Overflow
or by amir
Published on 2009-11-25T12:34:27Z
Indexed on
2010/04/02
13:03 UTC
Read the original article
Hit count: 222
jQuery
I'm trying to make an ajax search for a website,
HTML :
<form id="search" method="post" action="search.php">
<input type="text" name="search" />
<input type="image" name="submit" alt="search" src="images/buttons/search.gif" />
</form>
$(function() {
var search_text = '';
$('form#search input[name=submit]').click(function() {
search_text = $('form#search input[name=search]').val();
$.get('../search.php',{ s: search_text });
return false;
});
});
in the search.php file I have the following
<?php
$search = $_GET['s'];
if (isset($_POST['submit_x'])) {
$search = $_POST['search'];
$search = str_replace(' ','',$search);
$search = strtolower($search);
if($search == 'kingbabychosenheart' || $search == 'chosenheart' || $search == 'beltchosenheart') {
echo "<meta http-equiv='refresh' content='0;url=chosen_heart.php'>";
}
else {
echo "<meta http-equiv='refresh' content='0;url=not_found.php'>";
}
}
?>
but this doesn't work, what else do I have to do to make this work?
thanks
© Stack Overflow or respective owner