Skip to content

Instantly share code, notes, and snippets.

@Torokun
Created February 7, 2016 14:45
Show Gist options
  • Save Torokun/283c7c51af6330c3ac6f to your computer and use it in GitHub Desktop.
Save Torokun/283c7c51af6330c3ac6f to your computer and use it in GitHub Desktop.
// 処理A(Ajax)して処理B(Ajax)して処理C(Ajax)して、その後に処理Dをする
$(function(){
var _resultA = null;
var _resultB = null;
var _resultC = null;
function processA() {
// Aの処理(Ajax呼び出し)
$.get(url1, dataA, function(data, textStatus, jqXHRn){
// なんか処理して次の処理を呼ぶ
_resultA = hogehoge;
processB();
});
}
function processB() {
// Bの処理(Ajax呼び出し)
$.get(url2, dataB, function(data, textStatus, jqXHRn){
// なんか処理して次の処理を呼ぶ
_resultB = hogehoge;
processC();
});
}
function processC() {
// Aの処理(Ajax呼び出し)
$.get(url3, dataC, function(data, textStatus, jqXHRn){
// なんか処理して次の処理を呼ぶ
_resultC = hogehoge;
processD();
});
}
function processD() {
// Dする
someProcess();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment