Here is the jQuery structure that I am currently working with:
$(document).on('click', '.view-details', function () {
$(this).prop("disabled", true);
// API call1
// API call2
// API call3
$(this).prop("disabled", false);
}
I implemented the disabling and enabling functionality to prevent multiple clicks by users, as this was causing various issues.
However, a challenge I am facing is that the API calls are Asynchronous, and I wish to avoid making them Synchronous.
The issue arises where Line 5 may execute before the completion of API calls, which is not desirable. Additionally, enabling/disabling on each success or error of APIs seems like a cumbersome task.
Anyone have any suggestions on how to ensure that Line 5 executes only after the successful completion of API calls 2, 3, and 4?