我有这两组代码,一个是点击按钮时提示,
$('.button_class').click(function(){
var baker_url = base_url + 'baker/baker/manage/Bread/1';
var answer = confirm('Are you sure?');
if(answer == true){
// if this is true, i will call an external script so that within this condition that process will be executed
}
else if(answer == false){
return false; // exits
}
});
然后这里的这段代码是负责在单击按钮时执行该过程的代码,
$('.another_button_class').click(function(e){
e.preventDefault();
var baker_url = base_url + 'baker/baker/manage/Bread/1';
var form = '#'+ $(this).attr('rel');
var url = $(form).attr('action');
var target = '#'+ $(form).attr('rel');
$(target).slideUp();
$.post(url, $(form).serialize(),function(data) {
$(target).html(data).slideDown(function(){
if(data == '<div class="ok">Added</div>'){
setTimeout(refresh,1000)
c();
window.location = baker_url; // sets the url after refreshing
}
});
});
});
在第一个函数中answer == true
,我想执行后一个函数(单击按钮时执行进程的函数)。
我真的有可能调用另一个函数或事件处理程序来在另一个函数中执行它的进程吗?