1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| $( "#city" ).autocomplete({
minLength: 2,
scrollHeight: 220,
source: function(req, add){
$.ajax({
url:"/search.php?callback=?",
type:"get",
dataType: 'json',
data: 'city='+req.term,
async: true,
cache:false,
success: function(data){
var suggestions = [];
//process response
$.each(data, function(i, val){
suggestions.push(val.value);
});
//pass array to callback
add(suggestions);
}
});
},
open: function() {
$( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
},
close: function() {
$( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
}
}); |
Partager