-2
我想在春天得到自動完成。它的通話網址,但沒有返回列表春季控制器不返回列表成ajax成功函數
我的控制器代碼是這樣的......
@RequestMapping(value = "purchase/ajaxcitySearchGeneral", method = RequestMethod.GET)
[email protected] Map < String, List <MasterPart>> getZipcodes()
{
List <MasterPart> zipcodes = new ArrayList <MasterPart>();
List <MasterPart> zipcodes = itemService.getItem();
System.out.println("Test Value" + zipcodes);
Map < String, List <MasterPart>> zipMap = new HashMap < String, List <MasterPart>>();
zipMap.put("zipcodes", zipcodes);
System.out.println("Test Value2" + zipMap);
return zipMap;
}
Ajax代碼是這樣的...
<script>
$(function() {
$("#itemNameAuto").autocomplete({
source: function (request, response) {
$.ajax({
url: 'ajaxcitySearchGeneral.htm',
dataType: "json",
data: {
maxRows: 10,
startsWith: request.term
},
success: function (data) {
alert(data);
response($.map(data.zipcodes, function (item) {
return {
label: item.name,
value: item.name
};
}));
}
});
},
minLength: 1,
open: function() {
$(this).removeClass("ui-corner-all").addClass("ui-corner-top");
},
close: function() {
$(this).removeClass("ui-corner-top").addClass("ui-corner-all");
}
});
});
</script>
您在警報得到什麼..? – 2014-08-28 06:50:06