如何在程序中获取自动完成jquery ajax的id
$("#firstname")
.autocomplete({
source: function(request, response) {
$.ajax({
url: "search.php",
dataType: "json",
data: { term: request.term },
success: function(data) {
response(
$.map(data.myData, function(item) {
return {
label: item.title,
value:item.turninId
}
});
)
}
});
}
});
PS:这是自动填充jquery api:http://api.jqueryui.com/autocomplete/
的文档答案 0 :(得分:0)
$( "#firstname" ).autocomplete({
source: function( request, response ) {
$.ajax( {
url: "search.php",
dataType: "json",
data: {
term: request.term
},
success: function( data ) {
response( $.map( data.myData, function( item ) {
return {
label: item.title,
value: item.turninId
}
}));
}
});
},
select: function( event, ui ) {
$( "#firstname" ).val( ui.item.label);
$( "#fname" ).val( ui.item.value);
return false;
}
});