gpt4 book ai didi

javascript - Ajax 调用在 Internet Explorer 9 和 Internet Explorer 10 中不起作用

转载 作者:行者123 更新时间:2023-11-30 18:02:42 27 4
gpt4 key购买 nike

我使用此功能使用 ajax 显示项目页面。它在 Chrome 上运行良好,但在 Internet Explorer 上运行不正常。

<script type="text/javascript">
function grabInfo(str)
{
if (str=="")
{
document.getElementById("contentDiv").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("contentDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","get_property.php?q="+str,true);
xmlhttp.send();
}
</script>

此函数在 Chrome 上返回更新的结果。但在 Internet Explorer 中,此函数返回以前的结果。如果我使用 Ctrl+Shift+Del 清除 session ,系统会显示更新的结果。为什么会这样?你能帮忙吗?

提前致谢....

最佳答案

Internet Explorer 缓存响应。您可以使用 Math.random() 将随机值添加到请求 URL 的查询字符串,或者在服务器端脚本中包含响应 header 。

Cache-Control: no-cache, no-store

关于javascript - Ajax 调用在 Internet Explorer 9 和 Internet Explorer 10 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16536639/

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