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');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 电脑开机过商标后就直接这样,求解各位
  • ¥15 mysql , 用自己创建的本地主机和用户名 登录不上
  • ¥15 关于#web项目#的问题,请各位专家解答!
  • ¥15 vmtools环境不正常
  • ¥15 请问如何在Ubuntu系统中安装使用microsoft R open?
  • ¥15 jupyter notebook
  • ¥30 informer时间序列预测
  • ¥20 SSR引物多态性分析
  • ¥15 大漠插件在Win11易语言注册调用和免注册灵异事件,VS上注册调用完全没问题
  • ¥15 Addressable缓存机制做热更新的问题