Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php $row = get_row_index(); ?>
- <tr data-rownum="'. $row .'">
- <td>
- <span class="deletecontrat iconfont_d" data-toggle="tooltip" data-placement="right" title="Effacer ?">r</span>
- </td>
- </tr>
- jQuery( document ).on( 'click', '.deletecontrat', function() {
- $rownumjs = $(this).parent().parent().data("rownum");
- jQuery.post(
- ajaxurl,
- {
- 'action': 'mon_action',
- 'param': $rownumjs
- }
- ,
- function(response){
- console.log(response);
- }
- );
- });
- function add_js_scripts() {
- wp_enqueue_script( 'script', get_template_directory_uri().'/custom/js/ajax.js', array('jquery'), '1.0', true );
- wp_localize_script('script', 'ajaxurl', admin_url( 'admin-ajax.php' ) );
- }
- add_action('wp_enqueue_scripts', 'add_js_scripts');
- function mon_action() {
- $param = $_POST['param'];
- delete_row("field_5c8fa4201b65f", 1, $post_id);
- echo $param;
- die();
- }
- add_action( 'wp_ajax_mon_action', 'mon_action' );
- add_action( 'wp_ajax_nopriv_mon_action', 'mon_action' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement