Communication issue between PHP and jQuery -


i have page generated php this:

<?php     //in original code, retrieved databas..     $users = array(         array('id'=>1, 'login'=>'login1', 'email'=>'email1')     );       foreach($users $user){         echo '<tr><td>'.$user['login'].'</td><td>'.$user['email'].'</td><td><button class="button-delete">delete</button></td></tr>';     } ?> 

then, in front side have script:

$('.button-delete').click(function(){     var id=0;     alert(id); }); 

my aim make delete button perform ajax call delete user. till didn't got there yet, problem how user id?

you can send id within button data , after.

<?php     //in original code, retrieved databas..     $users = array(         array('id'=>1, 'login'=>'login1', 'email'=>'email1')     );       foreach($users $user){         echo '<tr><td>'.$user['login'].'</td><td>'.$user['email'].'</td><td><button class="button-delete" data-id="'.$user['id'].'">delete</button></td></tr>';     } ?>  $('.button-delete').click(function(){     var id=$(this).data('id');     alert(id); }); 

Comments

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -