Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. <?php $row = get_row_index(); ?>
  2. <tr data-rownum="'. $row .'">
  3. <td>
  4. <span class="deletecontrat iconfont_d" data-toggle="tooltip" data-placement="right" title="Effacer ?">r</span>
  5. </td>
  6. </tr>
  7.  
  8. jQuery( document ).on( 'click', '.deletecontrat', function() {
  9.  
  10. $rownumjs = $(this).parent().parent().data("rownum");
  11.  
  12. jQuery.post(
  13. ajaxurl,
  14. {
  15. 'action': 'mon_action',
  16. 'param': $rownumjs
  17. }
  18. ,
  19. function(response){
  20. console.log(response);
  21. }
  22. );
  23.  
  24. });
  25.  
  26. function add_js_scripts() {
  27. wp_enqueue_script( 'script', get_template_directory_uri().'/custom/js/ajax.js', array('jquery'), '1.0', true );
  28. wp_localize_script('script', 'ajaxurl', admin_url( 'admin-ajax.php' ) );
  29. }
  30. add_action('wp_enqueue_scripts', 'add_js_scripts');
  31.  
  32.  
  33.  
  34.  
  35. function mon_action() {
  36.  
  37. $param = $_POST['param'];
  38.  
  39. delete_row("field_5c8fa4201b65f", 1, $post_id);
  40.  
  41. echo $param;
  42. die();
  43. }
  44. add_action( 'wp_ajax_mon_action', 'mon_action' );
  45. add_action( 'wp_ajax_nopriv_mon_action', 'mon_action' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement