I have an ajax call which is fired when a click event occurs on document. The ajax call seems to be executing twice and I am not sure why this happens.
This is running on MySQL 5, PHP 5 and Apache 2
My question is : How can I prevent ajax call from firing twice?
Here is my JQuery code:
$(document).on('click', '.edit_quyet_dinh', function(){
var ma_quyet_dinh = $(this).attr("id");
var ma_cong_trinh = $(this).attr("data-id");
$.ajax({
url:"fetch_quyet_dinh.php",
method:"POST",
data:{ma_quyet_dinh:ma_quyet_dinh,ma_cong_trinh:ma_cong_trinh},
dataType:"json",
success:function(data){
$('#ten_quyet_dinh').val(data.ten_cong_trinh);
$('#shct_qd').val(data.so_hieu);
$('#so_quyet_dinh').val(data.so_quyet_dinh);
$('#ngay_duyet').val(data.ngay_duyet);
$('#ma_quyet_dinh').val(data.ma_quyet_dinh);
$('#insert_qd').val("Update");
$('#add_quyet_dinh').modal('show');
}
});
});