The title does not explain much, but I have a code that gives a number to the class, because it is in foreach
, it would be
<button class='accept ".$accept++."'>Accept</button>
the $ accept ++ is added one for each time it passes through the foreach, and I want that if you click on the button an ajax request is sent with the content of the row:
It is explained like this: If I have the name Juan and accept 1, I want you to send a request with that information, then it would be Luis and accept 2, etc ...
AJAX:
$( ".accept" ).click(function() { // aqui quiero el accept 1, accept 2...
$.ajax({
type: "POST",
url: "url.php",
data: {'nombre':'<?php echo $nombre; ?>'}, //el nombre del row sacado con foreach
success: function(){
console.log("Yes");
},
error: function(){
console.log("error");
}
});
});