简体   繁体   中英

How Bootstrap modal get 'id' from url

I want to get 'id' from url and using in my Bootstrap modal. How to get this '69' .In my modal i using this '69' with SQL request.

在此处输入图片说明

I Hope, your JS code is somehow similar to it.

<script>
    $('.Contact').click(function(){
        var id=$('.Contact').val();
        $.ajax({url:"ModalPage.php?id="+id,cache:false,success:function(result){
            $(".modal-content").html(result);
        }});
    });
</script>

In, ModalPage.php

<?
$id=$_GET['id'];

  // Now, use this 'id'.
?>

an easy trick is to make hidden input inside modal code as below

<div id="myModal">
   <form>
     <input type="hidden" value="<?php echo isset($_GET['id']?$_GET['id']:''); ?>" /> <!--if you want to make it hidden-->
     <label>ID = <?php echo isset($_GET['id']?$_GET['id']:''); ?></label><!--if you want to display-->
      <!--your code-->
   </form>
</div>

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