问题
i´ve a problem by reload elements not from cache.
Frist of all, my head:
<meta http-equiv="expires" content="0"><!-- no cache-->
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-store" />
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"/>
<meta http-equiv="content-script-type" content="text/javascript">
So I´ve JavaScript var in external .txt documents written and changed by .php My task is to implement this var into HTML and keep them actual every 10 sec. I used following code:
<script type="text/javascript" id="Perso_UHS_1"></script>
<script>
function reldataperso(){
var dper = new Date();
document.getElementById('Perso_UHS_1').src =
"PersonalkapazitatUHS1.txt?time" + dper.getTime();
};
setInterval(function(){
reldataperso();
alert("test")
}, 10000);
</script>
</head>
<body onload="reldataperso()">
OK, this works with .jpg oder .html but not by .txt in the head. The Browser don´t try to reload, by the alert was coming every 10 seconds...
Do you have any ideas?
回答1:
There are several issues that may be the cause of it.
- No semicolon after
alert("test")
- The function
reldataperso
doesn't have a closing bracket (right before the</script>
there should be a}
.
回答2:
You have the 'cache-control' one wrong defined, maybe it fixes it
<meta http-equiv='cache-control' content='no-cache'>
来源:https://stackoverflow.com/questions/48911775/document-getelementbyidid-src-reload-not-from-cache