title: Call a web method using jQuery Ajax
body: <p>I want to create an <code>Autocomplete</code> field for a search option. I have tried with following code. </p>
  
  <p>But <strong>the web method doesn't fire</strong> when the <code>Autocomplete</code> function is execution.
  What will be the reason ? </p>
  
  <p>Here is the jQuery function:    </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(function () { $("#&lt;%=tags.ClientID %&gt;").autocomplete({
           source:function (request, response) {
           $.ajax ({
               type: "POST",
              contentType: "application/json; charset=utf-8",
              url: "~/Services/AutoComplete.asmx/GetFarmersByName",
              data: "{ 'name' : '" + $("#&lt;%=tags.ClientID %&gt;").val() + "'}",
              dataType: "json",
              async: true,
              dataFilter: function (data) { return data; },
              success: function (data) {
                        response($(data.d, function (item) {
                                  return            {
                                      value: item.AdrNm
                                  }
                         }));
                       },
             error: function (XMLHttpRequest, textStatus, errorThrown) {
                              alert(textStatus);
                          }
                      });
                  }
  
              });
          });
   &lt;/script&gt;
  </code></pre>
  
  <p>Here is the web method</p>
  
  <pre><code>    [WebMethod]
      [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
      public List&lt;FMISPersonalDataViewByName_Result&gt; GetFarmersByName(string name)
      {
          this._personalData = new personalData();
          int cky = 45;
          CdMa cdMas = new CdMa();
          cdMas = this._personalData.getcdMasByConcdCd2(cky, "AdrPreFix", true);
          int prefixKy = cdMas.CdKy;
  
          List&lt;FMISPersonalDataViewByName_Result&gt; list = new List&lt;FMISPersonalDataViewByName_Result&gt;();
  
          list = this._personalData.GetPersonalDataByName(prefixKy, cky, name);
          return list;
      }
  </code></pre>