I have a list of users selected on my page using a PHP loop. When I click each username, a Bootsrap Modal popup window appears and displays additional information about the user. The links are as follows.
<a href="#user" data-toggle="modal" data-id="{$user['id']}">UserName</a>
As you can see, I pass in the user ID of the Bootstrap modality to use it to retrieve other user information by calling get_user_by_id() in the Bootstrap Modal module.
Modal Looks like this:
<div class="modal fade" id="user"> <div class="modal-header"> <button class="close" data-dismiss="modal">×</button> <h3>Modal header</h3> </div> <div class="modal-body"> <?php $user = get_user_by_id($id); ?> <input type="text" name="bookId" id="bookId" value=""/> </div> </div>
JS code is like this
$('#user').on('show.bs.modal', function (event) { var button = $(event.relatedTarget) var id = button.data('id') })
According to the above JS code, I have a user var id in var id variable. But I can not imagine how to use this value for the above PHP function as an argument.
Is there any possible way to do this?
I edited the question to be more unique in AJAX methods, most of the answers were based on AJAX
PS: I am very new to PHP and Bootstrap.
javascript php twitter-bootstrap-3 bootstrap-modal
Tharindulucky
source share