Click here to Skip to main content
15,031,219 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i`m trying to make a auto complete text box in php. here is my JavaScript code

PHP
<script src="assets/js/jquery-1.10.2.js"></script>
<script src="assets/js/jquery-1.3.2.min.js"></script>
<script src="assets/js/jquery-ui-1.10.4.custom.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
$('#search').autocomplete({
source : 'search-job.php',
minLength:2
});
});
</script>


here is my html code
HTML
<input type="text" id="search" class="form-control input-lg col-xs-4" name="search">

here is my search-job.php

PHP
<?php
include 'connectdb.php';
if(isset($_REQUEST['term']))
exit ();
$rs=  mysql_query("select * from jobs where `title` like '%"  . ucfirst($_REQUEST['term']). "%' ORDER BY id ASC LIMIT 0,10") or      die(mysql_error());
$data=  array();
while($row=  mysql_fetch_assoc($rs,MYSQL_ASSOC)){
$data[]=array(
'label'=>$row['title'],
'value'=>$row['title']
);
}
echo json_encode($data);
flush();

i`m getting correct values in search-job.php. but it is not catching by html but when i run code nothing happened? why is that?

this is how it's looks on network tab

image
Posted
Updated 8-Jul-15 19:45pm
v3
Comments
[no name] 9-Jul-15 0:31am
   
http://phpcoderzone.blogspot.in/2012/11/auto-complete-text-box-with-php-jquery.html

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900