Peace And blessing be upon you :)
Basically I have two function, each performs an ajax call. Something like:
1:
function step1(){
var formdata = new FormData();
formdata = {
'URI': sendtosev
};
$.ajax({
type: 'POST',
url: 'http://localhost:20012/serv1',
data: formdata,
contentType: "text/html",
success: function(result){
$('.UID).text(result);
}
});
}
2:
function step2(){
var stkname=$('.UID').text();
var formdata = new FormData();
formdata = {
'URI': stkname
};
$.ajax({
type: 'POST',
url: 'http://localhost:20012/serv1',
data: formdata,
contentType: "text/html",
success: function(result){
alert(result);
}
});
}
FYI: step1 ajax is performed to get some data from serv1 servlet. and step2 ajax uses step1 ajax output and through it get some new Data from serv2.
Now Currently What I'm doing is:
$(function({
step1();
step2();
});
Through this step2
FormData is null because step1
has not yet finished it's call and haven't received its output.
Question: How to find if step1()
ajax is completed and have received the output So I could call step2()
;