简体   繁体   中英

How can I get the value of data-id and post it into another page using jquery post?

Here is my code

<a href="#view_contact" class="btn btn-info btn-xs view" data-id="<=$row['ADMINISTRATOR_ID'];?>" data-toggle="modal">View</a>

I need to be able to get the value of data-id and post it into another page. How will I do it? Kinda new at this stuff. I tried using the code below but it does not work.

$(document).on('click', '.view', function() {

    var val = $(this).attr('data-id');

    $.post('edit.php', {id: val}, function(data){
        console.log(data);
    });

});

first of all correct this line with below, because of "<=$row['ADMINISTRATOR_ID'];?>" will not print value

<a href="#view_contact" class="btn btn-info btn-xs view" data-id="<?=$row['ADMINISTRATOR_ID'];?>" data-toggle="modal">View</a>

or

<a href="#view_contact" class="btn btn-info btn-xs view" data-id="<?php echo $row['ADMINISTRATOR_ID'];?>" data-toggle="modal">View</a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM