ajax request rely on the previous one
Posted
by
Lynn
on Stack Overflow
See other posts from Stack Overflow
or by Lynn
Published on 2012-11-29T04:51:57Z
Indexed on
2012/11/29
5:03 UTC
Read the original article
Hit count: 396
I want to do something like this:
$.ajax({
url: SOMEWHERE,
...
success: function(data){
// do sth...
var new_url = data.url;
$.ajax({
url: new_url,
success: function(data){
var another_url = data.url;
// ajax call rely on the result of previous one
$.ajax({
// do sth
})
}
})
},
fail: function(){
// do sth...
// ajax call too
$.ajax({
// config
})
}
})
the code looks like shit.
I wonder how to make it looks pretty. Some best practice?
© Stack Overflow or respective owner