Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/451.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无缓存和更新不';不要在IE 10中使用JSP和Javascript_Javascript_Html_Jsp_Internet Explorer_Caching - Fatal编程技术网

无缓存和更新不';不要在IE 10中使用JSP和Javascript

无缓存和更新不';不要在IE 10中使用JSP和Javascript,javascript,html,jsp,internet-explorer,caching,Javascript,Html,Jsp,Internet Explorer,Caching,我已经关闭了缓存,并使用javascript从jsp页面中的rest调用手动检索状态。每个人都喜欢它(Chrome、FireFox、Safari、Opera),当然IE8-11除外 大部分工作由getStatus()完成。这使用XMLHttpRequest从REST调用中检索一组json状态。它解析json并将状态复制到td标记的innerHTML中。我使用setInterval()每5秒执行一次 我使用jsp顶部附近的缓存控制、Pragma和Expires头关闭缓存 症状是状态从未更新 代码如

我已经关闭了缓存,并使用javascript从jsp页面中的rest调用手动检索状态。每个人都喜欢它(Chrome、FireFox、Safari、Opera),当然IE8-11除外

大部分工作由getStatus()完成。这使用XMLHttpRequest从REST调用中检索一组json状态。它解析json并将状态复制到td标记的innerHTML中。我使用setInterval()每5秒执行一次

我使用jsp顶部附近的缓存控制、Pragma和Expires头关闭缓存

症状是状态从未更新

代码如下:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<% 
//tell browsers and proxy servers not to cache this page
if ("HTTP/1.1".equals(request.getProtocol()))
{
    response.setHeader("Cache-Control", "no-cache");
}
response.setHeader("Pragma","no-cache" );
response.setDateHeader("Expires", 0);
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Application Title</title>
<link rel="stylesheet" type="text/css" href="<c:out value="${pageContext.request.contextPath}"/>/css/Admin.css" />

<script type="text/javascript">
    // need enough time for jbehave to parse the page
    var REFRESH = 5000; // 5 seconds

        // Update status after 5 seconds has elapsed.
    setInterval("jobStatus();", REFRESH);

    function jobStatus() {
        getStatus();
    }

    function getStatus() {
        var xhttpRequest = getXMLHttpRequest();
        xhttpRequest.open("GET", "<c:out value="${pageContext.request.contextPath}"/>/admin/resyncPhs/getstatus",  true);
        xhttpRequest.onreadystatechange = function() {
            if (xhttpRequest.readyState === 4) {
                if (xhttpRequest.status === 200) {
                     var json = xhttpRequest.responseText;
                     var parsed = JSON.parse(json);

                     document.getElementById("status").innerHTML = parsed.status;
                     document.getElementById("progress").innerHTML = parsed.progress;
                }
            }
        };
        xhttpRequest.send(null);
    }

    function getXMLHttpRequest() {
        if (window.XMLHttpRequest) {
            return new XMLHttpRequest();
        } else {
            return new ActiveXObject("Microsoft.XMLHTTP");
        }
    }

</script>

</head>
<body onLoad="jobStatus();">
                <table class="resyncBodyTable">
                    <tr>
                        <td />
                        <td>Labels:</td>
                        <td id="status">${status}</td>
                        <td id="progress">${progress}</td>
                    </tr>
                </table>
</body>
</html>

申请名称
//需要足够的时间让jbehave解析页面
变量刷新=5000;//5秒
//5秒后更新状态。
setInterval(“jobStatus();”,刷新);
函数jobStatus(){
getStatus();
}
函数getStatus(){
var xhttpRequest=getXMLHttpRequest();
xhttpRequest.open(“GET”,“/admin/resyncPhs/getstatus”,true);
xhttpRequest.onreadystatechange=函数(){
如果(xhttpRequest.readyState==4){
如果(xhttpRequest.status==200){
var json=xhttpRequest.responseText;
var parsed=JSON.parse(JSON);
document.getElementById(“status”).innerHTML=parsed.status;
document.getElementById(“progress”).innerHTML=parsed.progress;
}
}
};
xhttpRequest.send(空);
}
函数getXMLHttpRequest(){
if(window.XMLHttpRequest){
返回新的XMLHttpRequest();
}否则{
返回新的ActiveXObject(“Microsoft.XMLHTTP”);
}
}
标签:
${status}
${progress}

有什么线索吗?

IE比其他浏览器更需要说服力:

response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
response.setHeader("Pragma","no-cache");

这些参数是否会导致其他浏览器出现问题,还是只需应用于IE?它们不会导致其他浏览器出现问题。