Good day forum.
I have a question, how can I do to be able to execute two events with javascript and ajax.
function validar(){
$(document).ready(function(){
$(document).on('submit','#addproduct',function(){
var data = $(this).serialize();
$.ajax({
type: 'POST',
url:'index.php?view=addreceipt',
data: new FormData(this),
contentType: false,
cache: false,
processData: false,
success:function(data){
$('#result').html(data).fadeIn();
$('#result').html(data);
}
});
return false;
});
});
}
The previous codes enter my records. And I have this other that makes me a query and shows me the folio. But what I want is to execute the two in my same function (validate), where the first one of adding records (first code) is executed and then the one of the folio (second code) I already require the last page that was entered in code 1. I hope you have given me to understand.
$(document).ready(function(){
$('#addproduct').on('submit',function(e){
e.preventDefault();
$.get('./?action=generatefolio',$('#addproduct').serialize(),function(data){
$('#folio').val(data);
});
$('#folio').val(data);
});
});