如何使用webservice jquery创建ajax自动完成搜索发送两个值
我将向API发送两个值,并且api提供一些json值。我将在建议下拉列表中显示该值
<script>
$(function() {
function log( message ) {
$( "<div>" ).text( message ).prependTo( "#log" );
$( "#log" ).scrollTop( 0 );
}
var vv = 'caselaw';
$( "#city" ).autocomplete({
source: function( request, response ) {
$.ajax({
type: "POST",
url: "http://54.255.134.169/streetsmart/v1/searchenginesuggested",
dataType: "jsonp",
data: {lawtype: 'caselaw',word:request.term },
success: function(data) {
alert(data.result);
response(data);
}
});
},
minLength: 2,
});
});
</script>