drqvsx1228 2014-10-13 01:55 采纳率: 0%
浏览 123

单击时使用Jquery刷新div

Lets say I have a page with div and mysql data in it. For example code below:

<div id="example">
  <table class="table table-striped table-bordered">
    <thead>
      <tr>
        <th>#</th>
        <th>Name</th>
      </tr>
    </thead>
    <tbody>

      <?php $num_rows=1 ; // store the record of the "tblstudent" table into $row while ($row=m ysqli_fetch_array($result)) { // Print out the contents of the entry echo '<tr>'; echo '<td>' . $num_rows . '</td>'; echo '<td>' . $row[ 'name'] . '</td>'; $num_rows++;
      } ?>

    </tbody>
  </table>
</div>

If I want to only refresh certain part of my page in this case the <div id="example">, How can I do that with just a single page and not using .load() or $.post. Is it actually possible??

  • 写回答

2条回答 默认 最新

  • duanhe0817825 2014-10-13 02:06
    关注

    What you posted is PHP - within PHP there's no way to update the page at all. You'd be using JavaScript do that.

    If you want to refresh a certain part of your page, AJAX is typically the way to do it (either $.ajax or .load()). Since you don't want/are unable to use AJAX, an IFRAME is really the only other way to do it. Frame out your content in a separate page, then include it via an IFRAME. You can use one of these two methods to refresh it:

    document.getElementById('#FRAME').contentDocument.location.reload(true);
    
    var iframe = document.getElementById(FrameId);
    iframe.src = iframe.src;
    
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号