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.
In reply to Re^3: webperl: fetching data over the web
by haukex
in thread webperl: fetching data over the web
by LanX
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |