title: jquery ui autocomplete with list<> object
body: <p>i'm working on a credit card application. 
  here is my web method:</p>
  
  <pre><code>[System.Web.Services.WebMethod]
  public static List&lt;database&gt; kartListele(int bin)
  {
  
      SqlConnection con = new SqlConnection("Server=.\\SQLEXPRESS;Database=kredikart;Integrated Security=True;");
      database db = new database();
  
      List&lt;database&gt; dondurulecek = new List&lt;database&gt;();
      SqlCommand cmd = new SqlCommand("listele", con);
      cmd.CommandType = CommandType.StoredProcedure;
      cmd.Parameters.Add("@binNo", SqlDbType.Int).Value = bin;
      con.Open();
  
      using (SqlDataReader dr = cmd.ExecuteReader())
      {
          if (dr.HasRows)
          {
              while (dr.Read())
              {
                  db.banka_adi = dr.GetString(0);
                  db.type = dr.GetString(1);
                  db.sub_type = dr.GetString(2);
                  dondurulecek.Add(db);
              }
          }
      }
      con.Close();
  
  
      return dondurulecek;
  }
  </code></pre>
  
  <p>but i dont know how to transfer my "dondurulecek" object to autocomplete function in jquery. i tried so many examples in many sites but it didnt work. </p>
  
  <p>i need an ajax function to use this list object.</p>
  
  <p>Any help?</p>
  
  <p>edit: i wrote this code to default.aspx:</p>
  
  <pre><code> &lt;link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" type="text/css" /&gt;
    &lt;script src="http://code.jquery.com/jquery-1.9.1.js"&gt;&lt;/script&gt;
    &lt;script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
  $(function() {
      $(".araTxt").autocomplete({
          source: function(request, response) {
              $.ajax({
                  url: "WebService.asmx/kartListele",
                  data: "{ 'bin': '" + request.term + "' }",
                  dataType: "json",
                  type: "POST",
                  contentType: "application/json; charset=utf-8",
                  success: function(data) {
                      response($.map(data.d, function(item) {
                          return {
                                  value: item
                      }
                      }))
          },
                  error: function(XMLHttpRequest, textStatus, errorThrown) {
                      alert(textStatus);
                  }
              });
          },
          minLength: 5
      });
      });
  
    &lt;/script&gt;
  
     &lt;asp:Textbox  ID="query" runat="server" CssClass="araTxt"/&gt;
  </code></pre>