I should mention that I have been doing a lot of work recently using the new
Async / Await feature in JavaScript that is ideal for complex tasks that would involve a lot of AJAX calls.
Most script solutions involve a handful of AJAX calls for which jQuery alone is perfectly adequate. I have written hundreds of such solutions using no more that say six AJAX calls. But recently some clients have brought to me problems that might involve hundreds of AJAX calls sometimes recursive in nature. Whole new schemes of writing JavaScript need to be created and it takes a dozen or so such tasks to get a good handle of how to implement these solutions. But the benefit is enormous as the resulting code is quite short and reads as if it was synchronous.
Here is a tiny example of an asynchronous function
doit() that fetches two URLs provided as parameters:
var doit = async function (url1, url2) {
var response1 = await fetch(url1);
var xml1 = await response1.text();
var response2 = await fetch(url2);
var xml2 = await response2.text();
}
You will note that there are no
callbacks,
then() methods or unnecessary
indention used and the code reads as if it was
synchronous (executes line after line) even though it is
asynchronous. This is because the async function
doit() suspends itself while it is waiting for the fetch response to arrive and resumes execution afterwords - all without blocking other running tasks or locking up the browser's display.
If you need a script solution to your problem feel free to contact me off-world.