javascript - Binding jquery autocomplete with json data.Autocomplete not working -
firstly, loading data on document ready
, save inside global variable after trying bind autocomplete text box. problem getting error uncaught typeerror: object not function
my implemented as
var jsondata; $(document).ready(function () { function split(val) { return val.split(/,\s*/); } function extractlast(term) { return split(term).pop(); } $.ajax({ url: "/webservice1.asmx/getemailswithnames", type: "post", data: "{}", datatype: "json", contenttype: "application/json;charset=utf-8", success:function(data){ jsondata = data; callonsuccess(); }, error: function (result) { alert('some error'); } }); }); function callonsuccess() { $("#<%=txtemailaddresses.clientid%>").autocomplete({ minlength: 0, source: jsondata, focus: function (event, ui) { $("#<%=txtemailaddresses.clientid%>").val(ui.item.email); return false; }, select: function( event, ui ) { return ; } }) .autocomplete("instance")._renderitem = function (ul, item) { return $("<li>") .append("<a>" + item.name + "<br>" + item.email + "</a>") .appendto(ul); }; }
the data getting in way variable jsondata
object {d: array[10]} d: array[10] 0: object 1: object 2: object 3: object 4: object 5: object 6: object 7: object 8: object 9: object length: 10 __proto__: array[0] __proto__: object
what's wrong it? why autocomplete not functioning.
secondly, requirement select multiple values ie show multiple emails on textbox separated ,
.
how this? required!!
Comments
Post a Comment