AJAX Timeout not working

AJAX Timeout not working

Hi,

First off, great job guys. I love this library.

Now, I am having one problem with the .ajax() function. My problem is, the timeout value seems to be completely ignored.

Here is a code snippet:

  1. function send_request(request_object)
  2. {
  3.    var req_data = "request_object=" + escape(JSON.stringify(request_object));
  4.    /* Reboot never returns, so time out fast! */
  5.    var timeout = 5000;
  6.    if (request_object.command == "reboot")
  7.       timeout = 250;
  8.    /* Used by the timeout callback */
  9.    g_ajax_cur_cmd = request_object.command;
  10.   
  11.    var resp_text =
  12.       $.ajax({
  13.          url:      "/cgi-bin/channel_interface.cgi",
  14.          data:     req_data,
  15.          timeout:  timeout,
  16.          dataType: "text",
  17.          method:   "POST",
  18.          async:    false,
  19.          cache:    false,
  20.          error:    function(xmlhttp_request, status, error)
  21.          {
  22.             if (status == "timeout")
  23.             {
  24.                if (g_ajax_cur_cmd == "reboot")
  25.                {
  26.                   notify_success("The reboot command was successfully issued. Please " +
  27.                                  "wait about one minute, then reload this page.");
  28.                }
  29.                else
  30.                {
  31.                   notify_error("The channel is not responding. Please reload this" +
  32.                                "page and try again.");
  33.                }
  34.             }
  35.          }
  36.       }).responseText;
  37.    g_ajax_cur_cmd = null;
  38. }
The idea is that when the underlying hardware is restarted (this is a control page for a device), we should time out very quickly, rather than locking the browser. I have stepped though with a debugger, and the 250ms value is definitely being inserted when the reboot command is issued. Any idea why this is not working?

Thanks!