Forum Discussion
_anomDiebolt_
7 years agoQrew Elite
Tip of the hat! This is the best question asked all year.
First, you have to realize that most of the applications of using JavaScript with QuickBase are workarounds and they may well embrace tricks, shortcuts, assumptions or goals that you would not use if you were developing a solution from scratch where you could control all technical aspects of the solution.
So the simplest solution to using your code as you wrote it would be to just make all jQuery AJAX calls synchronous by adding this line of code:
My professional colleagues would be aghast that I just suggested that you could use synchronous AJAX calls because asynchronous calls are all but the norm for most greenfield development.
Use it if you want, but there is good reason to master asynchronous programming as it will greatly expand your understanding of the process and propel you to even greater capabilities of what can be achieved using script with QuickBase.
First, you have to realize that most of the applications of using JavaScript with QuickBase are workarounds and they may well embrace tricks, shortcuts, assumptions or goals that you would not use if you were developing a solution from scratch where you could control all technical aspects of the solution.
So the simplest solution to using your code as you wrote it would be to just make all jQuery AJAX calls synchronous by adding this line of code:
$.ajaxSetup({async: false});And maybe add a spinner to indicate there are AJAX calls in flight:
$.ajaxSetup({async: false});
$("<img>", {
src: "https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif",
id: "QBU_Spinner"
}).css({
position: "fixed",
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)"
}).appendTo("body");
for (var i = 0; i < 5; i++) {
$.get(url,
act: "API_DeleteRecord",
rid: i
);
}
$("#QBU_Spinner").hide();
My professional colleagues would be aghast that I just suggested that you could use synchronous AJAX calls because asynchronous calls are all but the norm for most greenfield development.
Use it if you want, but there is good reason to master asynchronous programming as it will greatly expand your understanding of the process and propel you to even greater capabilities of what can be achieved using script with QuickBase.