Guest User

Untitled

a guest
Jan 4th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. jQuery('#button').click( function () {
  2.  
  3. var vocabulary = jQuery('.selected').children("input").attr("id");
  4. var user = jQuery('#id_user').attr("name");
  5.  
  6. jQuery.ajax({
  7. url: removeVoca.ajax_url,
  8. type:'post',
  9. data : {
  10. action : 'renove_vocabulary',
  11. id_vocabulary : vocabulary,
  12. id_user : user
  13. },
  14. success : function(reponse){
  15.  
  16. //delete the row
  17. table.row('.selected').remove().draw( false );
  18. },
  19. error: function(xhr){
  20. //error handling
  21. console.log("suppression echoué")
  22. }});
  23.  
  24. } );
  25. } );
  26.  
  27. add_action( 'wp_ajax_renove_vocabulary', 'renove_vocabulary' );
  28.  
  29. function renove_vocabulary() {
  30.  
  31. $id_user = $_POST['user_id'];
  32. $id_vacabulary = $_POST['vocabulary_id'];
  33.  
  34.  
  35. global $wpdb;
  36.  
  37. $reponse = $wpdb-> delete ('wp_user_vocabulary', array ('vocabulary_id' => $id_vacabulary , 'user_id' => $id_user ), array('%d', '%d'));
  38.  
  39.  
  40. wp_die();
  41.  
  42. }
Add Comment
Please, Sign In to add comment