Back Midas Rome Roody Rootana
  Midas DAQ System  Not logged in ELOG logo
Entry  29 Oct 2015, Konstantin Olchanski, Info, synchronous ajax deprecated 
    Reply  29 Oct 2015, Amy Roberts, Info, synchronous ajax deprecated 
       Reply  30 Oct 2015, Stefan Ritt, Info, synchronous ajax deprecated 
          Reply  18 Nov 2015, Amy Roberts, Info, synchronous ajax deprecated 
             Reply  18 Nov 2015, Konstantin Olchanski, Info, synchronous ajax deprecated 
                Reply  19 Nov 2015, Amy Roberts, Info, synchronous ajax deprecated 
       Reply  02 Nov 2015, Konstantin Olchanski, Info, synchronous ajax deprecated 
          Reply  17 Nov 2015, Konstantin Olchanski, Info, synchronous ajax deprecated 
             Reply  18 Nov 2015, Amy Roberts, Info, synchronous ajax deprecated 
                Reply  26 Nov 2015, Konstantin Olchanski, Info, browser compatibility test: synchronous ajax deprecated 
                Reply  27 Nov 2015, Konstantin Olchanski, Info, synchronous ajax deprecated 
Message ID: 1129     Entry time: 29 Oct 2015     In reply to: 1128     Reply to this: 1130   1131
Author: Amy Roberts 
Topic: Info 
Subject: synchronous ajax deprecated 
We're using mhttpd for calls that end up working better with asynchronous requests, and we've built up sort of a parallel, asynchronous library using javascript Promises.

The Promises (which are in the ES6 spec) have worked incredibly well for building well-behaved, sequential calls to mhttpd.  Personally, I also find their syntax much easier to wrap my
head around, especially compared to callbacks.

I'd be happy to add these functions to midas.js if there's general interest. 

> If using a synchronous AJAX call, such as "foo=ODBGet("/runinfo/state");", google chrome will prints this to the javascript console:
> 
> "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/."
> 
> The referenced URL has this text:
> 
> "Synchronous XMLHttpRequest outside of workers is in the process of being removed from the web platform as it has detrimental effects to the end user's experience. (This is a long 
> process that takes many years.) Developers must not pass false for the async argument when the JavaScript global environment is a document environment. User agents are strongly 
> encouraged to warn about such usage in developer tools and may experiment with throwing an InvalidAccessError exception when it occurs."
> 
> Then jQuery say this: http://api.jquery.com/jquery.ajax/
> 
> "As of jQuery 1.8, the use of async: false with jqXHR ($.Deferred) is deprecated; you must use the success/error/complete callback options instead of the corresponding methods of the 
> jqXHR object such as jqXHR.done() or the deprecated jqXHR.success()."
> 
> This sounds rather severe but one must flow with the flow. Synchronous RPC is out, async is in.
> 
> Many of the old MIDAS AJAX functions are fully synchronous (i.e. "foo=ODBGet("/blah");"), some more recent ones support both sync and async use (i.e. ODBMCopy()).
> 
> All the newly added functions *must* by async-only. For example, all the new JSON-RPC functions are async-only and require the use of callbacks to get at the data.
> 
> Converting existing javascript custom pages from sync AJAX (hah! it's SJAX, not AJAX) will require some work, and one might as well start today.
> 
> Personally, I think this excessive use of callbacks for all javascript web page programming is an unnecessary PITA, but I also do understand the motivation
> of people who write web browsers and javascript engines - removal of support for synchronous RPC makes many things much simpler -
> and even small speedup of javascript execution and better browser efficiency is welcome improvements (but not free improvements - as old web pages need to be converted).
> 
> K.O.
ELOG V3.1.4-2e1708b5