weixin_33722405 2013-07-25 03:27 采纳率: 0%
浏览 143

Bootstrap Modal初始化和AJAX

I face an issue with bootstrap modal, what I'm trying to do is to insert HTML contents inside bootstrap modal using AJAX but when I load the modal nothing is displayed and when I inspect the modal I can see the html contents from AJAX, I figured out that this because the time that is needed to initialize the modal faster than the time that AJAX takes to load the html contents.

Is there a way to make the modal and the AJAX load at the same time or if there is another way to make html contents from ajax display inside a modal body.

The Modal:

<div class="modal hide fade" id="MobileAppPromoDiv">
<div class="modal-body">
</div>
<div class="modal-footer">
    <a href="#" class="btn btn-success" data-dismiss="modal">Ok</a>
</div>

The Ajax:

$.get("URL",{action:21},function(htmlContent){
     $('#MobileAppPromoDiv').find('.modal-body').append(htmlContent);
                $('#MobileAppPromoDiv').modal('toggle');
});
  • 写回答

2条回答 默认 最新

  • weixin_33743880 2013-07-25 04:20
    关注

    You can setTimeout() method to delay the madel initialization for some time to load the HTML content using AJAX.

    评论

报告相同问题?

悬赏问题

  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条