Skip to content
Advertisement

how do make waiting for ajax to complete

I newbie. I have a function application for employment (apply-job).What I do is submit the request with an ordinary link, with a click-function applied on it but processing time is quite long. I want disable “#apply-job” avoid click too much or disable window and fade for ajax to complete. Thank. My JS:

JavaScript

Advertisement

Answer

ajax has await option. You can use it to make the execution wait till the ajax all is done. Make sure you combine it with async which will tell there’s an asynchronous step in the function. See below snippet

JavaScript

Update: to make sure the click is disabled while ajax is working, add a disabled attribute and assign the click only when the attribute is not present. Clear the attribute once process is complete.

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement