$("#bankIdAutoSuggest").autocomplete({
			source : function(request, response) {
				$.ajax({
					url : $('#contextPath').val() + "/autoSuggestBank?bankName=" + $("#bankIdAutoSuggest").val(),
					dataType : "json",
					data : {
						q : request.term
					},
					success : function(data) {
						console.log(data);
						if (data == "") {
							$('#bankId').val("");
							$('#bankNameTemp').val("");
							$('#bankIdAutoSuggest').val("");
						//	$("#bankError").html("Invalid Bank");
							$("#bankError").html("");
							$("#bankError").show();
						} else {
							response($.map(data, function(item) {
								return {
									label : item.bankName,
									value : item.bankName,
									id : item.bankId
								};
							}));
						}
					}
				});
				console.log('---> ');
			},
			minLength : 1,
			select : function(event, ui) {
				$(this).val(ui.item.label);
				$('#bankId').val(ui.item.id);
				$('#bankNameTemp').val(ui.item.label);
				$('#bankIdAutoSuggest').val(ui.item.label);
				$("#bankError").html("");
				$("#bankError").hide();
			},
			open : function() {
				$(this).removeClass("ui-corner-all").addClass("ui-corner-top");
			},
			close : function() {
				$(this).removeClass("ui-corner-top").addClass("ui-corner-all");
			}
		});


@RequestMapping(value = "/autoSuggestBank", method = RequestMethod.GET)
	@ResponseBody 
	public List<BankDTO> autoSuggestBank(@RequestParam String bankName){
		logger.info("PaymentDetailsController::autoSuggestBank::start");
		List<BankDTO> bankDTOs = paymentService.fetchBank(bankName);
		logger.info("PaymentDetailsController::autoSuggestBank::end");
		return bankDTOs;
	}

Leave a Reply

Your email address will not be published. Required fields are marked *