title: How to fire a method in aspx.cs file using ajax
body: <p>I wanna <strong>call a method</strong> on <strong>PersonalDetails.aspx.cs</strong> page <strong>using Ajax</strong>. I have tried to it using following code. but it doesn't worked. 
  <strong>I just wanna fire the method included in the PersonalDetails.aspx.cs</strong> How do i do it? :)
  Can somebody help me. </p>
  
  <pre><code>&lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"&gt;
  &lt;/script&gt;
  
  
   &lt;script type="text/javascript"&gt;
      $(document).ready(function () {
          $("input").keydown(function () {
              $("input").css("background-color", "yellow");
          });
          $("input").keyup(function () {
              $("input").css("background-color", "pink");
  
              $.ajax({
                  type: "POST",
                  contentType: "application/json; charset=utf-8",
                  url: "PersonalDetails.aspx/GetFarmersByName",
                  data: { name: +request.term },
                  dataType: "json",
                  async: true,
                  dataFilter: function (data) { return data; },
                  success: function (data) {
                      return data;
                  },
                  error: function (XMLHttpRequest, textStatus, errorThrown) {
                      alert(textStatus);
                      alert(errorThrown);
                  }
              });
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>This is The method I wanna fire..</p>
  
  <pre><code>    [WebMethod]
      [ScriptMethod]
      public  bool GetFarmersByName(string name)
      {
          _personalData = new personalData();
          int cky = 45;
          CdMa cdMas = new CdMa();
          cdMas = _personalData.getcdMasByConcdCd2(cky, "AdrPreFix", true);
          int prefixKy = cdMas.CdKy;
  
          List&lt;FMISPersonalDataViewByName_Result&gt; list = new List&lt;FMISPersonalDataViewByName_Result&gt;();
  
          list = _personalData.GetPersonalDataByName(prefixKy, cky, name);
  
          if (list != null)
          {
              grvPersonalData.DataSource = list;
              grvPersonalData.DataBind();
              return true;
          }
          return false;
  
      }
  </code></pre>