Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #27191

Synchronous XMLHttpRequest deprecated

From Chuck Anderson <seemysig@thisis.invalid>
Newsgroups comp.lang.javascript
Subject Synchronous XMLHttpRequest deprecated
Date 2015-04-04 17:34 -0600
Organization A noiseless patient Spider
Message-ID <mfpsco$mn7$1@dont-email.me> (permalink)

Show all headers | View raw


The current Firefox displays this warning in the console when I use a 
synchronous XMLHttpRequest.

"Synchronous XMLHttpRequest on the main thread is deprecated because of 
its detrimental effects to the end user's experience. For more help 
http://xhr.spec.whatwg.org/"

I've read about the reasoning and understand the logic, ... although I 
believe this should be a decision left up to the page designer and not 
dictated by the browser developers.

That said, ...  most all of my synchronous "ajax" requests can be 
converted to asynchronous with no detrimental effect.

I do have one case, though, that needs to be synchronous.  I have 
written a file synch/backup web application for myself using Php, and 
JavaScript .  It compares - then copies (sync/backup) a list of files on 
a local server or on a remote server (using FTP).

During the copy process I provide progress feedback on the list of files 
being copied by opening an overlaying div with a table and using 
JavaScript to:

1. Create a new table row with the name of the file, it's size and a 
faux progress meter (animated gif).

2. Send a synchronous XMLHttpRequest to the local server to actually 
delete the file (local, LAN, or FTP remote).

3. Display the result ("deleted or failed") from the synchronous 
XMLHttpRequest response.

4.  Repeat the above process for every file in the list

Yes, it "locks up" my app during the process, but this is exactly what I 
want it to do so I can visualize the progress and see if there any 
errors or warnings from the Php copy process.

What it usually does it race through the list, displaying a summary at 
the end.

I like the way I implemented this, but it appears it will ultimately 
stop working in major browsers.  I tried an asynchronous approach, but 
it is too complex trying to keep track of the separate XMLHttpRequest 
responses - spaghetti.

Is there a way to make this synchronous copy process not be "in the main 
thread?"

Is there another way I should implement this - like move to an iframe 
(not div) and call a Php script that processes the whole list in one 
instance?  (I don't like using iframes - and won't it have the same 
effect anyway - lock up the page while it processes the list?)

Yes, this could leave the boundaries of a JavaScript forum, but the 
XMLHttpRequests are where it starts.

(I also created a web app with Php/JavaScript to play Rummy (with a 
local or remote opponent) and it requires synchronous calls so the 
display of cards on the screen stays in synch with the players moves. 
Losing synchronous requests will destroy that entire app.)

-- 
  *****************************
   Chuck Anderson • Boulder, CO
   http://cycletourist.com
   Turn Off, Tune Out, Drop In
  *****************************

Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Synchronous XMLHttpRequest deprecated Chuck Anderson <seemysig@thisis.invalid> - 2015-04-04 17:34 -0600
  Re: Synchronous XMLHttpRequest deprecated Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2015-04-05 08:09 +0800
  Re: Synchronous XMLHttpRequest deprecated Luuk <luuk@invalid.lan> - 2015-04-05 18:06 +0200
    Re: Synchronous XMLHttpRequest deprecated "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-04-05 10:42 -0700
      Re: Synchronous XMLHttpRequest deprecated Luuk <luuk@invalid.lan> - 2015-04-05 22:04 +0200
    Re: Synchronous XMLHttpRequest deprecated "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-04-05 22:59 +0200
      Re: Synchronous XMLHttpRequest deprecated Chuck Anderson <seemysig@thisis.invalid> - 2015-04-05 23:09 -0600
        Re: Synchronous XMLHttpRequest deprecated Tim Streater <timstreater@greenbee.net> - 2015-04-06 10:20 +0000
  Re: Synchronous XMLHttpRequest deprecated Silvio <silvio@internet.com> - 2015-04-05 23:41 +0200
    Re: Synchronous XMLHttpRequest deprecated Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-04-06 14:11 +0200
      Re: Synchronous XMLHttpRequest deprecated Tim Streater <timstreater@greenbee.net> - 2015-04-06 13:23 +0000
        Re: Synchronous XMLHttpRequest deprecated Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-04-06 15:36 +0200
          Re: Synchronous XMLHttpRequest deprecated Tim Streater <timstreater@greenbee.net> - 2015-04-06 18:26 +0000
            Re: Synchronous XMLHttpRequest deprecated Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-04-06 20:18 +0200
            Re: Synchronous XMLHttpRequest deprecated Denis McMahon <denismfmcmahon@gmail.com> - 2015-04-06 18:35 +0000
              Re: Synchronous XMLHttpRequest deprecated Tim Streater <timstreater@greenbee.net> - 2015-04-06 21:51 +0000
                Re: Synchronous XMLHttpRequest deprecated "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-04-06 23:33 +0200
              Re: Synchronous XMLHttpRequest deprecated Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-04-07 01:13 +0200
      Re: Synchronous XMLHttpRequest deprecated Silvio <silvio@internet.com> - 2015-04-07 09:16 +0200
        Re: Synchronous XMLHttpRequest deprecated Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-04-07 12:51 +0200
          Re: Synchronous XMLHttpRequest deprecated Silvio <silvio@internet.com> - 2015-04-07 14:55 +0200
            Re: Synchronous XMLHttpRequest deprecated Tim Streater <timstreater@greenbee.net> - 2015-04-07 14:23 +0000
              Re: Synchronous XMLHttpRequest deprecated Silvio <silvio@internet.com> - 2015-04-07 17:41 +0200
            Re: Synchronous XMLHttpRequest deprecated Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-04-07 15:37 +0200
              Re: Synchronous XMLHttpRequest deprecated Silvio <silvio@internet.com> - 2015-04-07 16:53 +0200
                Re: Synchronous XMLHttpRequest deprecated Tim Streater <timstreater@greenbee.net> - 2015-04-07 16:03 +0000
                Re: Synchronous XMLHttpRequest deprecated Silvio <silvio@internet.com> - 2015-04-07 17:47 +0200

csiph-web