title: jquery ajax call fails with 401 unauthorized
body: <p>I have a jquery ajax POST to a code-behind webmethod. In that webmethod i do a HttpWebRequest to a third party web api service that returns json.  Even though the httpwebrequest works fine, a popup appears in the browser asking me to enter credentials (authentication required). On my machine this works well, however when deployed it doesn't except if there is no data returned from the httpwebrequest call.</p>
  
  <p>The jquery call:</p>
  
  <pre><code>function serverCall(httpMethod, pageName, methodName, inputData, successCallback, errorCallback, disableGlobalAjaxEvents) {
  
      // Construct the url
      var url = pageName + "/" + methodName;    
  
      var triggerGlobalEvents = true;
      if (disableGlobalAjaxEvents &amp;&amp; disableGlobalAjaxEvents == true) {
          triggerGlobalEvents = false;
      }
  
      $.ajax({
          type: httpMethod,
          url: url,
          data: JSON.stringify(inputData),
          contentType: "application/json; charset=utf-8",
          global: triggerGlobalEvents,
          dataType: "json",
          success: function(msg) {
              if (successCallback) {
  
                  var parsedObject = JSON.parse(msg.d);
                  successCallback(parsedObject);
              }
          },
          error: function(error, status) {
              if (errorCallback) {
                  errorCallback(error, status);
              }
          }
      });
  </code></pre>
  
  <p>And here is the actual call:</p>
  
  <pre><code>serverCall("POST", "SomePage.aspx", "GetSomething", inpuData, onSuccess, onError, true);
  </code></pre>
  
  <p>The webmethod:</p>
  
  <pre><code>       [WebMethod(
            CacheDuration = 5,
            EnableSession = true)]
          public static string GetSomething(string user, string item)
  {
  // In the body i do the HTTPWebRequest that returns JSON
  }
  </code></pre>