Reputation: 1903
I have used the return false preventDefault stoppropogation but the the of them not stoping the condition to execute further when data is 1
$(document).on('click','.lunch_out',function(e){ //lunch out
var object = this;
$.post('attendance_action.php',{'action':'check_time'},function(data){ //check the lunch time reached or not
alert(data);
if ($.trim(data) == '1') {
alert();
bootbox.alert("Sorry! Lunch time Over.");
$(object).remove();
// e.stopPropagation();
e.preventDefault();
//return false;
}
});
$.post('attendance_action.php',{'action':'lunch_out'},function(data){
window.location.reload();
});
e.preventDefault();
});
Upvotes: 0
Views: 31
Reputation: 13699
You should set else
so the other post would run only if the data is not 1
$(document).on('click', '.lunch_out', function(e) { //lunch out
var object = this;
$.post('attendance_action.php', {
'action': 'check_time'
}, function(data) { //check the lunch time reached or not
alert(data);
if ($.trim(data) == '1') {
alert();
bootbox.alert("Sorry! Lunch time Over.");
$(object).remove();
} else { // your else
$.post('attendance_action.php', {
'action': 'lunch_out'
}, function(data) {
window.location.reload();
});
}
});
e.preventDefault();
});
Upvotes: 1