helloxielan 2014-08-28 09:42 采纳率: 0%
浏览 138

如何重新加载div

I have a little problem with reloading div content. I have a form which is split in 4 steps. On the second step people are able to add items (giftcards or checks) When someone adds a new item this item is added to an array which is stored in a session. After adding the item I would like to show the item to the customer so I wanted to refresh / reload the div with the PHP function that shows the data.

<div class="kosten" id="kosten">
                <?php
                    if($session->exists('stap2')) {
                        echo $lijst->output();
                    }
                ?>
</div>

The function exists is to check if a sessions has been set. The function output is a function to output html with session data.

So what have I tried so far: First I tried to do something like:

$('#kosten').load('index.php');

This however resulted in showing me the index.php but I was back at step 1. I also tried to add some JavaScript / jQuery to show step 2 again but this also didn't help

Second thing I tried:

setInterval(function() {
                    $('#kosten').text();
                }, 3000);

Which resulted in showing me a half blank page. It wouldn't reload the bottom half of the page. And with an interval you will also see that the div is being reloaded.

Third thing I have tried is to do another post to PHP. It would than echo $lijst->output() as a return. But this gave me an array instead of html

So what I would like to do is reload the div so not the page after a button of "add item" is clicked. Is there any other way of doing this?

Thanks in advance

  • 写回答

3条回答 默认 最新

  • weixin_33701617 2014-08-28 09:45
    关注

    jQuery has the option of adding a selector to do what you look for:

    $('#kosten').load('index.php #kosten');
    
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料