2016-05-17 5 views
-4

でのsetTimeoutを続行しますか?私が望むのは、クリックが起こるのを待つだけです。

function ajax(allowed){ 

    if(!allowed){ return false; } 

    //api function here 
} 

は今、これを呼び出す:

+1

それはあなたが – maioman

+0

は、なぜ、何を引き続き求めているものをはっきりしていないので、例のバイオリンを作りますか?あなたの目標はここにはっきりしていません – Liam

答えて

1

私はあなたがここにフラグを使用することができますね

$('#something').click(function(){ 
    //how to continue here? 
    ajax(false); 
}); 
あなたは、ユーザーが続行するアクションを確認したい場合は、この使用することもできる

function ajax(){ 
    if(confirm('Do you want to continue?')){ // prompts user to allow/disallow 
     //api function here 
    } 
} 
$('#something').click(function(){ 
    //how to continue here? 
    ajax(); 
}); 
1

function ajax(){

$('#something').click(function(){ 
    //you received button click event & your magic goes here & may b call your api whatever 
}); 

setTimeout(function(){ 
    //you cause button click event 
    $('#something').click(); 
},300); 

}

関連する問題

 関連する問題