title: Integrating Typeahead.js with ASP.Net Webmethod
body: <p>I am looking for an example for using Typeahead.js with a Asp.Net Webmethod.</p>
  
  <p>I have the example from <a href="http://twitter.github.io/typeahead.js/examples/" rel="nofollow">http://twitter.github.io/typeahead.js/examples/</a> working with the basic example, but I don't fully understand how to implement the Bloodhound functionality with a asp.net webmethod.</p>
  
  <p>The typeahead function is calling the WebMethod (I can see the step in the debugger) but there's nothing returned to the list for the TypeAhead.</p>
  
  <p>Here's the markup:</p>
  
  <pre><code>&lt;div class="input-group"&gt;
      &lt;asp:TextBox ID="tboxText" runat="server" CssClass="form-control autocomplete" placeholder="Look Up"&gt;&lt;/asp:TextBox&gt;
      &lt;span class="input-group-btn"&gt;
          &lt;asp:Button ID="btnAddItem" runat="server" Text="Add" CssClass="btn btn btn-amethyst" /&gt;
      &lt;/span&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And here's the jquery:</p>
  
  <pre><code>$(document).ready(function () {
          var textlookup = new Bloodhound({
              datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
              queryTokenizer: Bloodhound.tokenizers.whitespace,
              remote: '/WebServices/InternalMethods.asmx/TextAutocomplete?param=%QUERY' 
          });
  
          textlookup.initialize();
  
          $('.autocomplete').typeahead({
              hint: true,
              highlight: true,
              minLength: 1
          },
          {
              name: 'textlookup',
              displayKey: 'value',
              source: textlookup.ttAdapter()
          });
      });
  </code></pre>
  
  <p>And here is the WebMethod:</p>
  
  <pre><code>    [WebMethod]
      [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
      public List&lt;string&gt; TextAutocomplete(string param)
      {
          return Suggestions.TextAutocomplete(param);
      }
  </code></pre>
  
  <p>Any help is appreciated.</p>