1
Hello! I am using an ajax on a button so that when I click on it this submits a form, the button then changes from VALIDATE to VALIDATED, all without reloading the page.
Here’s the code:
$('#validar_form').submit(function(event){
$.ajax({
url: 'valida_horaextrarh.php',
type: 'post',
dataType:'html',
data: $('#validar_form').serialize(),
success: function(response, textStatus, jqXHR){
$('#principal').html(response);
},
error: function(jqXHR, textStatus, errorThrown){
console.log('error(s):'+textStatus, errorThrown);
}
});
});
The problem is that the current code only allows me to click the buttons in the order they are displayed, image below:
If I try to validate the Person 3 request, I need to validate Person 2 first, otherwise the button does not execute the ajax.
How to resolve this so I can click the buttons in any order?
Each line of this is inside a form ?
– Leandro Lima
There is a select collecting the rows in the database, a foreach that tables them for me while there is data, each row generates this button that submits a form to update the line saying that it was checked, the submit of this form uses ajax not to update the page and process the data.
– Fernando Gross
I ask the same as @Leandrolima... each line has its own form or the whole block is inside a form? Put the code that is possible to run/test otherwise it will be difficult to help.
– Fernando
Each line has a form, I even understood why the question, how it looks for the form ID the problem should be this, ajax stops at the first ID it finds, but how to solve I do not know.
– Fernando Gross