title: autocomplete with asp.net generated json
body: <p>I have the folowing script which does not seem to work.  The aspx page returns json similar to the json in the script below which has been commented out.  If I stick that json directly into the source as an array, it works perfectly.</p>
  
  <p>But as soon as I try to use the script below, I get no error messages or anything, nothing happens when i type into the autocomplete field.</p>
  
  <pre><code>$(document).ready(function(){
      $('#button').click(function() {
          alert($("#txtAllowSearchID").val()); 
      }); 
  
      //var $local_source = [ {id:0,value:"c++"}, {id:1,value:"java"}, {id:2,value:"php"}, {id:3,value:"coldfusion"}, {id:4,value:"javascript"}, {id:5,value:"asp"}, {id:6,value:"ruby"} ]; 
  
      $("#txtAllowSearch").autocomplete({
          source: function(request, response) {
              $.ajax({
                  type: "POST",
                  url: "test_array.aspx",
                  data: "{'prefixText': '" + $('#txtAllowSearch').val() + "'}",
                  contentType: "application/json; charset=utf-8",
                  dataType: "json",
                  success: function(data) {
                      response(data.d);
                  },
                  failure: function(errMsg) {
                      $('#errMessage').text(errMsg);
                  }
              });
          },
          select: function (event, ui) {
              $("#txtAllowSearch").val(ui.item.value); // display the selected text
              $("#txtAllowSearchID").val(ui.item.id); // save selected id to hidden input
          }
      });
  });
  </code></pre>
  
  <p>EDIT: I think the problem is in the aspx page:</p>
  
  <pre><code>objSQLCommand = New SqlCommand("select id, value from table1 where value like '%@prefixText%'", objSQLConnection)
  objSQLCommand.Parameters.Add("@prefixText", SqlDbType.VarChar, 255).Value = "ing"
  </code></pre>