So that's it... i have my jQuery Code like this:
jQuery:
<script type="text/javascript">
$(document).ready(function() {
$('#val').autocomplete({
source: "search.php",
});
});
</script>
HTML:
<input class="searchInput" id="val" name="val" type="text" />
PHP (search.php):
$con = mysql_connect("localhost","root","");
$db = mysql_select_db("x",$con);
$sql = mysql_query("SELECT * FROM opcionais WHERE Opcional LIKE 'Nokia%'");
$result = array();
while($linha = mysql_fetch_array($sql)){
$result[] = $linha['Opcional'];
}
echo json_encode($result);
But here's the deal... when i open my search.php it came to me all the result in json... then, if i try the autocomplete he load all the results....... for example...
In the search.php i receive:
["Nokia","Nokia Lumia"]
Ok... in autocomplete, when i type "LUMIA" the widget load "Nokia" too. Buuutt..... if i copy the result i get in "search.php" and paste in a variable at the jquery script, the autocomplete works just fine.
Anyone knows why my external source of results doesn't works like if i put the results direct on a variable together with the jQuery Code?
Thanks in advance and sorry for my poor english :-)
EDIT:
So i put more images to show what happens... that way it's not working, it's like the SOURCE cannot accept the "$('#val').val()"...

SOLVED
I've solved the problem by my self...
<script type="text/javascript">
$(document).ready(function(){
$('#val').keyup(function(){
var x = "search.php?ac=" + $('#val').val();
$('#val').autocomplete({
source: x,
minLenght:5,
});
});
});
</script>
thanks for all responses :-)