I am a bit stuck with the below issue, my code is similar to this:
function (){
var myVar = myFirstAjaxFunction()
$.ajax({
url: myUrl + myVar
....
})
}
My first ajax function is returning a string that I would like to use in the end of my function, but I do not know how to wait for the first function to be done.
I hope this is clear, thanks for your help!
5
Answers
You can use Async/Await:
Here is an example:
Or you pass callback :
and usage :
Return the promise from the ajax call. Example snippet for your reference
I think you should take help of callback function, please look at the below code. will help you.