title: asp.net jQuery json autocomplete data doesn't seem to be correct
body: <p>I am using jQuery to call a web service method to perform autocomplete but the data in the autocomplete/suggestion drop down of the textbox isn't the same as when I run the query directly.</p>
  
  <p>This is the jQuery that's inside the <code>document.ready</code> function:</p>
  
  <pre><code>$("#&lt;%=txtSearch.ClientID %&gt;").autocomplete({
          source: function (request, response) {
              $.ajax({
                  url: '../cspm/s3.asmx/SearchSrn1',
                  data: "{ 'prefixText': '" + request.term + "'}",
                  dataType: "json",
                  type: "POST",
                  contentType: "application/json; charset=utf-8",
                  success: function (data) {
                      response($.map(data.d, function (item) {
                          return {
                              label: item.split('-')[0],
                              val: item.split('-')[1]
                          }
                      }))
                  },
                  error: function (response) {
                      alert(response.responseText);
                  },
                  failure: function (response) {
                      alert(response.responseText);
                  }
              });
          },
  
          minLength: 2
      });
  </code></pre>
  
  <p>This is the code from the web service method:</p>
  
  <pre><code>&lt;WebMethod(), System.Web.Script.Services.ScriptMethod()&gt; _
  Public Function SearchSrn1(ByVal prefixText As String) As String()
  
      Dim results As New List(Of String)()
  
      Dim searchText As String() = prefixText.Split(New Char() {" "c})
  
      sql = New StringBuilder()
      sql.Append("select rownum,b.* from ")
      sql.Append("(select distinct a.* from imsi_keyword_lookup_b a ")
      sql.Append("where keyword like upper('%" + searchText(0).ToUpper() + "%') ")
  
      For i As Integer = 1 To searchText.Length - 1
          If searchText(i) &lt;&gt; "" Then
              sql.Append("and keyword like '%" + searchText(i).ToUpper() + "%' ")
          End If
      Next
  
      sql.Append("order by rank desc) b ")
      sql.Append("where rownum &lt;= 5 ")
  
      Using rdr As System.Data.IDataReader = db.ExecuteDataReader(sql.ToString())
          Dim counter As Integer
          While rdr.Read
              If (counter = 5) Then Exit While
              results.Add(String.Format("{0}-{1}", rdr("keyword"), rdr("keyword")))
              counter += 1
          End While
      End Using
  
      Return results.ToArray()
  
  
  End Function
  </code></pre>
  
  <p>When I type gif I am returned 5 results as I should but they all say GIF in the dropdown portion of the textbox. When I run the query with GIF as the keyword I get: <code>GIF-Q, GIF-160, GIF-Q180, GIF-H180, GIF-Q160</code>.</p>
  
  <p>Any ideas as to why I am not getting the correct data back?</p>