for below json
{ "partnernamelistbeanstruts2map": [ { "firstname": "sachin", "partnerid": 123 }, { "firstname": "ankit", "partnerid": 234 } ] }
what code should wright done jquery autocompleter.
here code.
here want autocomplete element's value sachin or ankit , id like 123 or 234 id of element.
$(document).ready(function() { $(function() { $("#search").autocomplete({ source : function(request, response) { $.ajax({ url : "list.action", type : "post", data : { term : request.term }, datatype : "json", success : function(data) { ****what should write here work code?**** } }); } }); });
according doc, should return data response
callback function.
a response callback, expects single argument: data suggest user. data should filtered based on provided term, , can in of formats described above simple local data. it's important when providing custom source callback handle errors during request. must call response callback if encounter error. ensures widget has correct state.
$(function($) { $("#search").autocomplete({ source : function(request, response) { $.ajax({ url : "list.action", type : "post", data : { term : request.term }, datatype : "json", success : function(data) { ***response (data) ;*** } }); } }); });
Comments
Post a Comment