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:
- function send_request(request_object)
- {
- var req_data = "request_object=" + escape(JSON.stringify(request_object));
- /* Reboot never returns, so time out fast! */
- var timeout = 5000;
- if (request_object.command == "reboot")
- timeout = 250;
- /* Used by the timeout callback */
- g_ajax_cur_cmd = request_object.command;
-
- var resp_text =
- $.ajax({
- url: "/cgi-bin/channel_interface.cgi",
- data: req_data,
- timeout: timeout,
- dataType: "text",
- method: "POST",
- async: false,
- cache: false,
- error: function(xmlhttp_request, status, error)
- {
- if (status == "timeout")
- {
- if (g_ajax_cur_cmd == "reboot")
- {
- notify_success("The reboot command was successfully issued. Please " +
- "wait about one minute, then reload this page.");
- }
- else
- {
- notify_error("The channel is not responding. Please reload this" +
- "page and try again.");
- }
- }
- }
- }).responseText;
- g_ajax_cur_cmd = null;
- }
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!