Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /** test.php **/
- <!DOCTYPE html>
- <html>
- <head>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
- <script
- src="https://code.jquery.com/jquery-3.2.1.min.js"
- integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
- crossorigin="anonymous"></script>
- </head>
- <body>
- <div id="myModal" class="modal fade" role="dialog">
- <div class="modal-dialog">
- <!-- Modal content-->
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal">×</button>
- <h4 class="modal-title">Modal Header</h4>
- </div>
- <div class="modal-body">
- <p>Some text in the modal.</p>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
- </div>
- </div>
- </div>
- </div>
- <ul>
- <li>Record 1 <button class="edit" data-id="<?= '1'; ?>">Edit</button></li>
- <li>Record 2 <button class="edit" data-id="<?= '2'; ?>">Edit</button></li>
- </ul>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
- <script>
- $('.edit').on('click', function(){
- var record_id = $(this).data('id');
- var data = {'edit_id' : record_id};
- $.ajax({
- url : "post.php",
- data : data,
- type: "POST",
- success : function(data) {
- console.log(data);
- $('#myModal .modal-body').html( data );
- $('#myModal').modal('show');
- }
- });
- })
- </script>
- </body>
- </html>
- <?php
- /** post.php **/
- <?php
- if (isset($_POST['edit_id'])) {
- // process your data and echo result
- echo "I want to edit this id: " . $_POST['edit_id'];
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement