私はこのajaxを持っています:
$.ajax({
type: "POST",
cache: false,
url: 'update_db.php',
beforeSend: function(){
$.ajax({
type: "POST",
cache: false,
async: "false",
dataType: "json",
url: 'check_db.php',
success: function(data){
var nowmod = new Date();
var lastmod = new Date(data[0].lastmod_date);
if(nowmod > lastmod){
//abort here the first ajax call and
//reload the page after 2.5 sec
setTimeout(function(){
location.reload();}, 2500);
}
}
});
},
success: function(data){
alert("success");
}
});
最初の ajax を JS var に入れて呼び出しようとしました
var.abort();
また、私は試しました
return false
すべての場合において、最初の ajax 呼び出しの成功イベントが機能しています: アラート「成功」!
Stackoverflowでケースを見たことがあります。
beforeSend : function(xhr, opts){
if(1 == 1) //just an example
{
xhr.abort();
}
},
私の問題は、ajax 呼び出しを中止する前に DB をチェックする必要があることです。どんな提案も歓迎します。ありがとう。