title: JQuery AutoComplete TextBox from database using AJAX PageMethods in ASP.Net is not Working in Internet Explorer
body: <p>I need to make the AutoComplete TextBox from database using AJAX and I have tried this.</p>
  
  <p>Html code...</p>
  
  <pre><code>&lt;script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.10.0.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.9.2/jquery-ui.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.9.2/themes/blitzer/jquery-ui.css"
      rel="Stylesheet" type="text/css" /&gt;
  &lt;script type="text/javascript"&gt;
      $(function () {
          $("[id$=txtSearch]").autocomplete({
              source: function (request, response) {
                  $.ajax({
                      url: '&lt;%=ResolveUrl("~/Default.aspx/GetCustomers") %&gt;',
                      data: "{ 'prefix': '" + 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);
                      }
                  });
              },
              select: function (e, i) {
                  $("[id$=hfCustomerId]").val(i.item.val);
              },
              minLength: 1
          });
      });  
  &lt;/script&gt;
  Enter search term:
  &lt;asp:TextBox ID="txtSearch" runat="server" /&gt;
  &lt;asp:HiddenField ID="hfCustomerId" runat="server" /&gt;
  &lt;asp:Button ID="Button1" Text="Submit" runat="server" OnClick="Submit" /&gt;
  </code></pre>
  
  <p>C# code</p>
  
  <pre><code>[WebMethod]
  public static string[] GetCustomers(string prefix)
  {
      List&lt;string&gt; customers = new List&lt;string&gt;();
      using (SqlConnection conn = new SqlConnection())
      {
          conn.ConnectionString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
          using (SqlCommand cmd = new SqlCommand())
          {
              cmd.CommandText = "select ContactName, CustomerId from Customers where ContactName like @SearchText + '%'";
              cmd.Parameters.AddWithValue("@SearchText", prefix);
              cmd.Connection = conn;
              conn.Open();
              using (SqlDataReader sdr = cmd.ExecuteReader())
              {
                  while (sdr.Read())
                  {
                      customers.Add(string.Format("{0}-{1}", sdr["ContactName"], sdr["CustomerId"]));
                  }
              }
              conn.Close();
          }
      }
      return customers.ToArray();
  }
  </code></pre>
  
  <p>It works fine in Chrome, Mozilla but not working in Internet Explorer 11 Compatibility Mode .. Is there a way to work it in IE Compatibility Mode ?
  I want to correct the error in Compatibility Mode,..
  In IE its showing an Error :</p>
  
  <blockquote>
    <p>JavaScript runtime error: 'JSON' is undefined</p>
  </blockquote>