I have a page generated from PHP like this:
<?php
//In my original code, this is retrieved from databas..
$users = array(
array('id'=>1, 'login'=>'login1', 'email'=>'email1')
);
foreach($users as $user){
echo '<tr><td>'.$user['login'].'</td><td>'.$user['email'].'</td><td><button class="button-delete">Delete</button></td></tr>';
}
?>
Then, in front side I have this script:
$('.button-delete').click(function(){
var id=0;
alert(id);
});
My aim is to make Delete button perform an ajax call to delete the user. Till now I didn’t got there yet, my problem is how to get the user ID?
You can send the id within the button data and easily get it after.