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

如何重新加载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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵