title: JQuery .ajax() function call not working, but success method runs
body: <p>I'm having trouble getting an ajax call to work on a webpage. The WebMethod works just fine. </p>
  
  <p>One potential problem that I might see is that the code that calls the ajax method is located in a UserControl that is embedded in a content page that lives in a master page. This page can only be accessed after .Net authentication is verified. I have no clue if any of this matter, I'm just including this information so there are no hidden aspects of this issue.</p>
  
  <p>Another potential issue may be in the Ajax call itself. I just can't see what the problem is. Most confusing of all, the success method in the ajax call runs.. there is no failure. More confusing, if I change the name of the WebMethod to something else entirely, the success method of the ajax call still runs. </p>
  
  <p>Any idea what may be going wrong here?</p>
  
  <pre><code>var sendingThis = { x: 'abc', y: 'def', z: 'ghi' }
  
  $.ajax(
  {
      type: "POST",
      url: "TestPage.aspx/someMethod",
      data: sendingThis,
      contentType: "application/json; charset=utf-8",
      dataType: "json",
      async: true,
      cache: false,
      success: function (msg)
      {
           //THIS STUFF GETS CALLED...always
      },//end success
  
      error: function () 
      { 
        //DOESN'T GET CALLED 
      }
  });
  </code></pre>
  
  <p>Codebehind method in TestPage.aspx:</p>
  
  <pre><code>[System.Web.Services.WebMethod]
  public static void someMethod(string x, string y, string z) 
  {
      //CODE THAT UPDATES DATABASE; *INDEPENDENTLY CONFIRMED WORKING* 
  }
  </code></pre>
  
  <p>The button that calls the code..:</p>
  
  <pre><code>&lt;asp:Button ID="btnSomeMethod" runat="server" OnClientClick="return someMethod(this);" Text="Runit" /&gt;
  </code></pre>
  
  <p>Some additional observations I have that may help or not. I've tried using <code>ResolveURL</code> with the .ajax() call's URL, didn't work. I've also tried <code>EnableSession:true</code> as an attribute for the Web Method. I've tried inserting a <code>ScriptManager</code> into the page with <code>EnablePageMethods="true"</code> and a <code>ScriptReference</code> to the .js file that holds the Ajax() call. No luck whatsoever. What on earth is going on?</p>
  
  <p>Another update: I checked the HTTP stream to see what the Response Header is from the the POST request. First off, it's returning 200 OK as the POST status code. Request seems all good. However, in the response header, I'm getting:</p>
  
  <pre><code>`"status":401,"headers":`
  </code></pre>
  
  <p>This is related to an authentication error. </p>