dongsuo0517 2017-01-28 08:57
浏览 46

如何在这个带有id的模态中显示.php文件?

My code works fine in this way

posts.php?id=<?php echo $post_id?; ?>

It goes to the link and shows the post.

I need to stop going in that link and show that inside the modal. How can i do it

Note: I can simply include that inside the modal but can not pass the id .

<li data-toggle="modal" data-target="#myModal"><a href="posts.php?id=<?php echo $post_id; ?>"  >See post</a></li>

<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">&times;</button>
<h4 class="modal-title">Post</h4>
</div>
<div class="modal-body">
            
//  include the posts.php  here
            
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>

</div>
</div>

</div>
  • 写回答

3条回答 默认 最新

  • drnzpd579935 2017-01-28 09:29
    关注

    we can do this using ajax see the below code

    in php file write the content what to display

    $("#dynamicdata").click(function(){
             var dyid=$(this).attr("posts_id");
            $.ajax({
                  url:"posts.php",
                  type:"post",
                   dsta:{'id':dyid},
                   success:function(data){
                       $('#myModalbody').html('');
                        $("#mymodelbody").html(data);
                  }
                 });
        });
    <li data-toggle="modal" data-target="#myModal" posts_id="<?php echo $post_id; ?>"  id="dynamicdata"><a href="#" >See post</a></li>
     <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">&times;</button>
        <h4 class="modal-title">Post</h4>
        </div>
        <div class="modal-body" id="mymodelbody">
                    
        //  include the posts.php  here
                    
        </div>
        <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
        </div>
        </div>
        </div>

    </div>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 在现有系统基础上增加功能
  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页