title: How to pass parameter in Json in data?
body: <p>I have a text box in aspx page. from that i need to send the text of the textbox in function in Json For that i have a method in server side.</p>
  
  <pre><code>   [WebMethod]
      public static OfficeDetails[] BindSearchDatatable(string officename)
      {
  
          DataTable dt = new DataTable();
          List&lt;OfficeDetails&gt; details = new List&lt;OfficeDetails&gt;();
  
          using (SqlConnection con = new SqlConnection(@"Data Source=GTL--7\SQLEXPRESS;Initial Catalog=master;Integrated Security=True"))
          {
              using (SqlCommand cmd = new SqlCommand("select  OfficeName,City,Country from Office where OfficeName like '%" + officename + "%'", con))
              {
                  con.Open();
                  SqlDataAdapter da = new SqlDataAdapter(cmd);
                  da.Fill(dt);
                  foreach (DataRow dtrow in dt.Rows)
                  {
                      OfficeDetails Office = new OfficeDetails();
                      Office.OfficeName = dtrow["OfficeName"].ToString();
                      Office.City = dtrow["City"].ToString();
                      Office.Country = dtrow["Country"].ToString();
                      details.Add(Office);
                  }
              }
          }
          return details.ToArray();
      }
  </code></pre>
  
  <p>and in .aspx page I have</p>
  
  <pre><code> $('#btnSearch').click
                              (
                                  function () {
                                      var searchtext = $("#txtSearch").val();
  
                                      alert(searchtext);
                                      $.ajax(
                                                  {
                                                      type: "POST",
                                                      url: "Gridview.aspx/BindSearchDatatable",
                                                      data: "{officename : New}",
                                                      contentType: "application/json; charset=utf-8",
                                                      dataType: "json",
                                                      async: true,
                                                      cache: false,
                                                      success: function (data) {
                                                          for (var i = 0; i &lt; data.d.length; i++) {
                                                              $("#gvDetails").append("&lt;tr&gt;&lt;td&gt;" + data.d[i].OfficeName + "&lt;/td&gt;&lt;td&gt;" + data.d[i].City + "&lt;/td&gt;&lt;td&gt;" + data.d[i].Country + "&lt;/td&gt;&lt;/tr&gt;");
                                                          }
                                                      },
                                                      error: function (x, e) {
                                                          alert("The call to the server side failed. " + x.responseText);
                                                      }
                                                  }
                                              );
                                      return false;
                                  }
                              );
  </code></pre>
  
  <p>Now my Question is I send the Parameter in data but i am getting an error The function is running well.I have tested it without parameter so its running well.so i thing some wrong things is going on passing the text value Of textbox in function.</p>