title: jQuery AJAX call to an ASP.NET WebMethod
body: <p>I have the following jQuery AJAX request:</p>
  
  <pre><code>function sendUpdate(urlToSend) {
      var code = AccessCode; 
      var url = urlToSend;
      var options = { error: function(msg) { alert(msg.d); },
                      type: "POST", url: "webmethods.aspx/UpdatePage",
                      data: "{ accessCode: " + code + ", newURL: '" + url + "' }",
                      contentType: "application/json; charset=utf-8",
                      dataType: "json",
                      async: true, 
                      success: function(response) { var results = response.d; } }; 
      $.ajax(options);
  }
  </code></pre>
  
  <p>And the corresponding ASP.NET WebMethod:</p>
  
  <pre><code>[WebMethod]
  public static bool UpdatePage(string accessCode, string newURL)
  {
      bool result = true;
      try
      {
          HttpContext.Current.Cache[accessCode + "l"] = newURL;
      }
      catch
      {
          result = false;
      }
  
      return result;
  }
  </code></pre>
  
  <p>That all used to work correctly with "async:false", however I have to get rid of it as it freezes the browser until the response is received. Now the AJAX request above returns "undefined". </p>
  
  <p>Could anybody tell me why it happens and where the problem is?</p>
  
  <p>Thanks.</p>