javascript - The "right" way to do synchronous HTTP request -


you came here chide me real use case.

in world of online education, there scorm courses. have make old scorm courses work on site. scorm courses "web based" , run in browser, expect run in iframe , expect parent supply getvalue method , setvalue.

so these scorm courses doing things parent.setvalue("score", "90") , moving on. function supposed return "false" if there issue.

scorm comes 90's, , in modern web know have callbacks/promises , http fails "often". might think solution setvalue writes local data , tries , retries until get's through, scorm course typically set move next screen if setvalue worked, shouldn't letting user advance unless setvalue saved on server.

tl;dr

assuming syncronous request requirement, right way it?

so far know of $.ajax({async:false ... browsers warn , sound they're going ignore request synchronous. thinking maybe using websockets or web workers or right way syncronous request in modern programming. don't know how make request that. , not allowed change code of scorm courses (they generated various course-making tools)

to clarify, have full control on implementation of setvalue function.

will $.ajax({async:false ... work long term? (5-10 years)

note: entirely acceptable in use case freeze ui until request either succeeds or fails. that's courses assume.

so far know of $.ajax({async:false… browsers warn that

this right way (if you're using jquery), sends synchronous xmlhttprequest. ignore warning. it's warning using outdated technology, know.

and sound they're going ignore request synchronous.

that's unlikely.

i thinking maybe using websockets or web workers or right way syncronous request in modern programming.

no, websockets , web workers asynchronous, can't use them make asynchronous request synchronous (in fact there's nothing lets this).

will $.ajax({async:false… work long term? (5-10 years)

we cannot know (and not crystal ball). might, in older browsers, or might not. browser vendors reluctant break compatibility of features run web, , synchronous requests still needed time time. @ point, few (important) web pages use (<1%, <1‰, whatever threshold decide on) , browsers confident remove it. @ point, business have realised deprecate these outdated course-making tools.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo