title: Calling a Web Service using jQuery to return a simple Boolean value
body: <p>I have an ASP.NET Web Forms application and on one of my .ASPX pages I have some javascript.</p>
  
  <p>In one part of the Javascript, I want to call a web service so I can perform a server-side function and return either a true or false value, then in the javascript I can perform one of two actions depending on the true or false value.</p>
  
  <p>I've not done any web services before and so I'm struggling with getting a simple value back to the JS.</p>
  
  <p>My WebService (LoginCheck.asmx) currently looks something like this:</p>
  
  <pre><code>[System.Web.Script.Services.ScriptService]
  public class LoginCheck : System.Web.Services.WebService
  {
      [WebMethod]
      public bool IsLoggedIn()
      {
          return UserService.IsAuthenticated();
      }
  }
  </code></pre>
  
  <p>My Javascript call currently looks something like this:</p>
  
  <pre><code>$.ajax({
      type: "GET",
      contentType: "application/json; charset=utf-8",
      url: "LoginCheck.asmx/IsLoggedIn",
      data: "{}",
      dataType: "json",
      success: function (response) {
          if (response) {
              alert('Logged in: true');
          } else {
              alert('Logged in: false');
          }
      }
  });
  </code></pre>
  
  <p>Despite having a breakpoint in my code on the 'IsLoggedIn' web service method, it never breaks on it. I have checked the 'console' in Google Chrome when the web service is supposed to be called and it says something along the lines of:</p>
  
  <p>"The following operations are supported...", and it shows my one 'IsLoggedIn' method, but all the content rendered in this console window is essentially an HTML page, with HTML markup.</p>
  
  <p>I don't appear to ever be a) breaking on the breakpoint in code or b) getting a response back to my javascript (hence neither of the js alerts shown in my code above are occurring).</p>