I have a form that when I submit it will check for some validation through jQuery AJAX call.
My code is like this:
$("#myForm").submit(function(){
.....
.....
.....
.....
.....
$.ajax({
type:"POST",
url:"<?php echo base_url();?>bTransJual/formTambahJual/ajaxCekStockJual/",
data: { prdIdUkuId: dataArrPrIdUkuId, qty: dataArrQty},
dataType : "json",
success: function(data){
if(data.sukses){
//validasi lolos
document.frmTransJual.submit();
}else{
//validasi gagal
psnErrNya = data.psnErr;
$("#psnNotifikasiAjax").html(psnErrNya);
$("#notifikasiAjax").show('normal');
$("#imgLoadSubmit").hide();
return false;
}
}
});
});
And my form tag:
<form name="frmTransJual" id="myForm" method="post" action="some_url.php">
If the ajax success it will return a value data, and if this data.sukses is true I want the form to submit it. i use document.frmTransJual.submit(); to submit it, but it doesn’t work. anybody have a solution for this?
The reason is that you are using a infinite loop.It will call the same funciton again.
you can use like this
create a div
})