in this page, I have this button (code below) that if clicked will trigger the script
button code (rolemanage.php) :
a href="<?= base_url('admin/roleaccess/') ?>" data-toggle="modal" data-target="#aksesModal" class="badge badge-warning aksesModal" data-id="<?= $r['id_lvl']; ?>" class="badge badge-warning">Akses</a>
onclick script (rolemanage.php)
$('.aksesModal').on('click', function() {
const id = $(this).data('id');
$.ajax({
url: "<?= base_url('admin/getMenuid'); ?>",
data: {
id: id
},
method: 'post',
dataType: 'JSON',
success: function(data) {
var strData = JSON.stringify(data);
}
});
});
so the var data success get the array back from admin/getMenuid and the result arrays in console like this :
(1) […] 0: Object { id: "4", menu: "Barang Habis Pakai" } length: 1
then after that I tried to make that object to string using json.stringify in success: function
and the result like this :
[{"id":"3","menu":"Menu"}]
the question is : when I tried call strData in this page (rolemanage.php) using
var_dump(json_decode($_POST['strData']));
it shows undefined index strData.
how to get the strData value then ?