I have an ajax function which is obviously by default asynchronous. But I've this function in the first step of a wizard. So when the function executes, the purpose is to save something and after saving it returns an ID of the last inserted row. Things works fine.
But the problem am facing is this is executing in the next step button of the wizard and so the ajax call is async, step clearly jumped to the next step. but the server side function still executes in the background. So in the second step I need that ID generated in the first step. But if the user immediately click on Next button on the second page, that will not get the ID since the process still running in server side. Ofcourse I can override this by validating the second page. But other than than I need to make a wait or delay after the first page ajax call initiated. That means I need a 2-3 seconds of delay when the user clicks on the next button of the first page, but after the Ajax request initiated.
How can make that work?
My AJAX call
Delay of 5 seconds
Only then wizard should step ahead