In my view I have the link, the modal box, and script. I have my ID on my modal but i can't send it on my controller.
The link:
<a href="#myModal" data-toggle="modal" id="<?php echo $salle['id_salle'];?>" data-target="#edit-modal"><span class="glyphicon glyphicon-pencil"></span></a>
My modal:
<div id="edit-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body edit-content"></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
And my script:
$( document ).ready(function() {
$('#edit-modal').on('show.bs.modal', function(e) {
var $modal = $(this),
Id = e.relatedTarget.id;
$.ajax({
method: 'POST',
url: 'index.php?section=gestion-salles',
data: 'id_salle='+Id,
success: function(data) {
alert(data);
$modal.find('.edit-content').html(Id + '<?php echo $test; ?> ' + 'id= <?php echo $id; ?>');
}
});
})
});
In my controller I defined a variable, $test
, and I recovered it. But I defined my variable $_POST['id_salle'] but can't recover it. I would like to send it to the controller and then do the processing but I can't.
Thank you.