in reply to Re: webperl: fetching data over the web
in thread webperl: fetching data over the web

From what I understood is my demonstrated js code synchronous and blocking. Running it directly works, also from the Dev console in FFM

I'm not sure Perl should return earlier than alert does.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

  • Comment on Re^2: webperl: fetching data over the web

Replies are listed 'Best First'.
Re^3: webperl: fetching data over the web
by haukex (Archbishop) on Nov 08, 2018 at 15:39 UTC
    From what I understood is my demonstrated js code synchronous and blocking.

    Sorry, I missed the third argument to your req.open() call that makes the request synchronous. But I did copy your third piece of example code exactly, and on my end it works, and only blocks the page while the fetch is running - which is to be expected, since it's a synchronous request. Not sure why it's failing for you, but like I said, check the browser's debugging tools (e.g. in Firefox, hit Ctrl+Shift+e).

    Note that synchronous XHR's aren't recommended, see e.g. here:

    Note: Starting with Gecko 30.0 (Firefox 30.0 / Thunderbird 30.0 / SeaMonkey 2.27), Blink 39.0, and Edge 13, synchronous requests on the main thread have been deprecated due to the negative effects to the user experience.

    Synchronous XHR often causes hangs on the web. But developers typically don't notice the problem because the hang only manifests during poor network conditions or slow server response. Synchronous XHR is now in deprecation state. Developers are recommended to move away from the API.

      I'm aware its deprecated but I only need it for a proof of concept and am suspecting the problem to be somewhere else.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice