Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7159615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:15:37+00:00 2026-05-28T13:15:37+00:00

We are binding global ajax handlers to check if the browser went offline :

  • 0

We are binding global ajax handlers to check if the browser went offline :

$(document).ajaxSend(function(event, xhr, settings, response){  
   if(!navigator.onLine){  
        xhr.abort();  
   }  
}

then we are showing a dialog to the user that the browser went offline and bind for the ‘online’ event to hide the dialog when the browser turns online again.

Is there Anyway (even a hacky one) to restart the Ajax request based on the old which fits in the old context?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:15:37+00:00Added an answer on May 28, 2026 at 1:15 pm

    Here’s the cleanest approach I can think of:

    1. A queue for caching AJAX request settings so each subsequent call doesn’t overwrite the previous one
    2. A conditional in the ajaxSend() handler that either pushes the calls on the queue for later or executes the entire queue.

      !(function($, window, undefined){
          var ajaxRequestQueue  = [],    // queue for requests that were made while offline
              isProcessingQueue = false;
      
          function processRequestQueue() {
              if (isProcessingQueue === true)
              {
                  return;
              }
      
              isProcessingQueue = true;
              while (settings = ajaxRequestQueue.shift())
              {
                  $.ajax(settings);
              }
              isProcessingQueue = false;
          }
      
          $(document).ajaxSend(function(event, xhr, settings, response){
              if (!navigator.onLine) {
                  // abort the original request
                  xhr.abort();
                  // push a copy of the request's settings on the queue
                  ajaxRequestQueue.push($.extend(true, {}, settings));
              }
              else if (ajaxRequestQueue.length > 0
                   && isProcessingQueue        === false)
              // there are calls on queue and we haven't triggered 'ajaxSend' ourselves
              {
                  processRequestQueue();
              }
          });
      
          // Bind to start processing the queue when the browser comes back online
          window.addEventListener("online", processRequestQueue);
      })(jQuery, window)
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've written a custom paging scheme using jQuery 1.8.0. I'm binding event handlers to
After binding the scroll event to an object, how can I get the amount
When binding code to the execution of an event using mxml, by assigning the
When my Wpf app starts up I get a BindingFailureException in Settings.Designer.cs [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
An ejb-jar deployed to jboss 7 has a jdni binding java:global/foo!IFoo. Jboss management console
var myCode = {}; (function( global ) { global.print = function(value){ alert(Values: + value);
I want to shorten settings bindings {Binding Source={x:Static properties:Settings.Default}, Path=Password} To something like {settingsBinding
I have to implement a 'global' search/filter function in my application. Each window that
When binding values to controls I have plenty of this: Text='<%# Bind(StartDate, {0:dd.MM.yyyy}) %>'
1) Binding to The following populates a READ ONLY WinFrms grid: Dim query =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.