I have this function :
$('button[name="submitbutton"]').click(function() {
var button = 0;
if ($(this).attr('value') == 0) {
$('.modal.hapus').modal({
closable : false,
onDeny : function(){
},
onApprove : function(){
$('.form.update').submit(function(e){
e.preventDefault();
alert("button : 1");
jQuery.ajax({
type: "POST",
url: "<?php echo base_url(); ?>" + "katalog/kelolaPerubahan/1",
dataType: 'json',
data: $(this).serialize(),
success: function(res) {
updateRow(res, '<?php echo base_url(); ?>');
}
});
});
}
}).modal('show');
} else {
$('.form.update').submit(function(e){
e.preventDefault();
alert(button);
jQuery.ajax({
type: "POST",
url: "<?php echo base_url(); ?>" + "katalog/kelolaPerubahan/" + button,
dataType: 'json',
data: $(this).serialize(),
success: function(res) {
updateRow(res, '<?php echo base_url(); ?>');
}
});
})
}
})
I have two button in my form, with different value. When the button value I clicked is not equal to 0, it looks good, and do the submit action as it should. But, when the value is 0, my goal is showing a modal that contain two option, cancel or ok. But, when the modal is showing, the page is reloading. How can I prevent this reload and wait until two option (cancel or ok) is choosen?