I need to add search suggestion to a text box. I was trying many ways. But I couldn't find correct way. I get data(arraylist) from back end using ajax.Then return it to jsp as json. Now I need to add search suggestion function to according to ajax success. dataType of ajax success is json.
$("#tagText").bind("keyup", function (event){
event.preventDefault();
var tagSuggest = $("#tagText").val();
var url= "../operation/SuggestSupport!searchSuggest.action?documentTag.tagText="+tagSuggest+"&page=0&activePage=0";
$.ajax({
type: "POST",
url: url,
dataType:"json",
success: function(data){
//search suggestions code
},
error: function (data){
alert("Error");
}
});
});
This is my text box
<div class="input-group">
<s:textfield name="document.tagText" id="tagText" cssClass="form-control" maxlength="100" autocomplete="off" style="width: 237px; border-radius: 4px;"/>
</div>