title: ASP.NET WebMethod returns whole page to JQuery ajax requests
body: <p>I am building a web application where I am calling a ASP.NET WebMethod from jQuery on click of a textbox. The problem is that it returns me the whole ASPX Page. How can I get just the values returned by the Web Method? This is my code:</p>
  
  <pre><code>$("#&lt;%= groupNameTxt.ClientID %&gt;").click(function () {
      $.ajax({
          url: "../UserGroups.aspx/GetGroupList",
          data: "{  }",
          // dataType: "json"
          type: "POST",
          // contentType: "application/json",
          success: function (data) { 
              alert(data);
          },
          error: function (data) { 
              alert('err');
          }
      });
  });
  </code></pre>
  
  <p>This is my WebMethod from CodeBehind</p>
  
  <pre><code>[System.Web.Services.WebMethod]
  public static List&lt;Groups&gt; GetGroupList(string mail)
  {
      List&lt;Groups&gt; empList = new List&lt;Groups&gt;();
      empList.Add(new Groups() { GroupID = 1, GroupName = "Admins" });
      empList.Add(new Groups() { GroupID = 2, GroupName = "Employees" });
      empList.Add(new Groups() { GroupID = 3, GroupName = "Engineers" });
      empList.Add(new Groups() { GroupID = 4, GroupName = "Managers" });
      empList.Add(new Groups() { GroupID = 5, GroupName = "Assistants" });
      return empList;
  }
  </code></pre>