在jquery自动刷新后,div弹出窗口无效

时间:2017-03-28 17:50:54

标签: javascript php jquery partial-page-refresh

我有一个刷新div的jquery但刷新后弹出窗口不能刷新数据。

<script type="text/javascript">
    $(function() {
        $.ajaxSetup ({
            cache: false
        });
        //Refresh trigger `#newORDERx`
        var auto_refreshes = setInterval(function () {$('#newORDERx').load('inc/restAdmin_orders_rcvz.php');}, 1000);
    });
</script>
<div id="newORDERx"></div>

当我像下面那样使用它然后弹出工作正常,但它不会刷新div。

<script type="text/javascript">
    $(document).ready(function(){
        $.ajaxSetup ({
            cache: false
            mainClass: 'pp-product-detail' // when i use this then popup works but then doesn't refresh the div
        });
        var auto_refreshes = setInterval(function () {$('#newORDERx').load('inc/restAdmin_orders_rcvz.php');}, 1000);
    });

</script>

pp-product-detail class

AJAX popup

if ($('.pp-product-detail').length) {
   $('.pp-product-detail').magnificPopup({
       type: 'ajax'
   });
}

restAdmin_orders_rcvz.php

<div class="col-lg-6">
  <div class="the-menu-item">
    <div class="image-wrap">
      <a class="pp-product-detail" href="product-detail-popup-rest-admin-order-rcv.php?iid=<?php echo $phporder; ?>">
      <img src="images/themenu/img-1.jpg" alt="">
      </a>
    </div>
    <div class="the-menu-body">
      <b><font color='red'> Order # </font> <?php echo $phporder; ?><br>
      <font color='red'> Items Included : </font> <?php echo $lrsa['count']; ?>
      <br><font color='red'>Dated : </font> <?php echo date("d/m/Y", strtotime($phpdates)); ?>
      </b>
    </div>
  </div>
</div>

2 个答案:

答案 0 :(得分:0)

好的......我很确定问题出在您的class,因为您重新编写了.pp-product-detail元素...

因此,请尝试将其更改为:

if ($(document).find('.pp-product-detail').length) {
   $(document).find('.pp-product-detail').magnificPopup({
       type: 'ajax'
   });
}

答案 1 :(得分:0)

我刚刚在restAdmin_orders_rcvz.php添加了以下文件并且工作正常。

<script type="text/javascript" src="js/scripts.js"></script>

<强> restAdmin_orders_rcvz.php

<div class="col-lg-6">
  <div class="the-menu-item">
    <div class="image-wrap">
      <a class="pp-product-detail" href="product-detail-popup-rest-admin-order-rcv.php?iid=<?php echo $phporder; ?>">
      <img src="images/themenu/img-1.jpg" alt="">
      </a>
    </div>
    <div class="the-menu-body">
      <b><font color='red'> Order # </font> <?php echo $phporder; ?><br>
      <font color='red'> Items Included : </font> <?php echo $lrsa['count']; ?>
      <br><font color='red'>Dated : </font> <?php echo date("d/m/Y", strtotime($phpdates)); ?>
      </b>
    </div>
  </div>
</div>