gpt4 book ai didi

在 Javascript 中使用设置间隔函数在 IE 中无法正确调用 PHP

转载 作者:行者123 更新时间:2023-11-29 04:59:48 25 4
gpt4 key购买 nike

我正在尝试使用以下代码显示在数据库中更新的消息

var showtime = setInterval('redirect()',5000);
////Redirecting to DB Status /////
function redirect()
{
xmlhttp = GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="isResultexist.php"
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

我在这里收集来自 PHP 的响应并使用它来更新 UI 上的消息这里的问题是它在 5 秒后调用时第一次工作正常,但在返回相同结果后甚至数据库已更新,

这适用于 Mozilla 和 google chrome 浏览器

问候赫曼特

最佳答案

IE 正在缓存响应,因此请尝试在您的 isResultexist.php 中设置一个过期 header ,为每个请求添加一个随机参数或从获取切换到发布(发布未缓存)。

关于在 Javascript 中使用设置间隔函数在 IE 中无法正确调用 PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2637129/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com