jquery - Ajax autocomplete with List of object in .Net not working -


i'm trying users name contains string ajax autocomplete without result here code client js

$("#<%= username.clientid %>").autocomplete({                  //  autofocus: true,                  minlength: 1,                  delay: 1000,                  source: function (request, response) {                      $.ajax({                          url: "default.aspx/ajaxgetusers",                          type: "post",                          datatype: "json",                          contenttype: "application/json; charset=utf-8",                           data: "{ 'nametosearch' : '" + $("#<%=username.clientid %>").val() + "'}",                        //  datafilter: function (data) { return data; },                           success: function (data) {                              response($.map(data, function (item) {                                  return {                                      label: item.name,                                      value: item.id                                  }                              }))                              //debugger;                          },                          error: function (result) {                              alert("error");                          }                      });                  },                  focus: function (event, ui) {                      $("#<%= username.clientid %>").val(ui.item.name);                      return false;                  },                   select: function (event, ui) {                      $("#<%= username.clientid %>").val(ui.item.name);                      $("#<%= userid.clientid %>").val(ui.item.id);                       return false;                  }              })              .autocomplete("instance")._renderitem = function (ul, item) {                      return $("<li>")                        .append("<a>" + item.name + "<br>" + item.id + "</a>")                        .appendto(ul);                  }; 

ajax request processing success 200 ok. code behind returning list of object.

{"d":[ {"__type":"school.userforautocomplete", "name":"ivanov ivan ivanovich","id":"4ff81581-e1ba-42b5-a8d8-d25ca509286f"},      {"__type":"school.userforautocomplete", "name":"brown john vasya","id":"695ef73c-3e1e-4877-bdd7-dfe166c5f155"}]} 

please detect wrong code ? tried in google result here, without result. must of material list of string not array of object.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -