The "Right" Way to Make a Synchronous HTTP Request

You probably came here to defeat me, but this is a real precedent.

There are SCORM courses in the online learning world. I have to do the old SCORM courses on the site. SCORM courses are web-based and run in the browser, but they expect to run in an iframe, and they expect the parent to provide the GetValue and SetValue methods.

So, these SCORM courses do things like parent.SetValue ("grade", "90") and move. This function is supposed to return false if there is any problem.

SCORM has been shipping since the 90s, and on the modern network we know that we have to make callbacks / promises, and http fails "often." You might think that the solution is SetValue, which writes to local data, and then tries and retries until it passes, but usually the SCORM course is configured only to go to the next screen if SetValue worked, so you should not allow the user advances if SetValue has not actually been stored on the server.

TL DR

Assuming a synchronous request is a requirement, what is the right way to do this?

So far I know $.ajax({async:false ..., but now browsers warn about this and sound like they are simply ignoring your request in order to be synchronous. I think maybe using websockets or web workers, or something, is the right way to make a synchronous request in modern programming. But I do not know how to make such a request. And I’m not allowed to change the SCORM course code (they are generated using various course creation tools)

To clarify, I have full control over the implementation of the SetValue function.

Will it $.ajax({async:false ...work in the long run? (5-10 years old)

NOTE. In this case, it is completely acceptable to completely freeze the user interface until the request completes successfully or fails. This is what the courses suggest.

+4
2

$.ajax({async:false…,

( jQuery), XMLHttpRequest. . , , .

, .

.

, , websockets -, - - .

, - - , , ( ).

$.ajax({async:false… ? (5-10 )

( SO - ). , , . , , . - () - (< 1%, < 1 ‰, , ), , , . , .

+5

, : .

:

, . , .

, , , .

, , , , , / . ( API SCORM) 'true' , , AJAX .

, LMS SCORM:

, LMS SCORM , JavaScript ( SCORM API). SCORM, , JS - . AJAX SCORM API.GetValue.

API.SetValue / JS, SCORM. JS- , ('true') ('false'). - AJAX - , API.Commit().

API.Commit(), AJAX, LMS . , , , , Commit(), 'true'. .

+3

All Articles