0

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?

Yserbius
  • 1,243
  • 11
  • 15

2 Answers2

0

There are several issues that may be the cause of it.

  1. No semicolon after alert("test")
  2. The function reldataperso doesn't have a closing bracket (right before the </script> there should be a }.
Yserbius
  • 1,243
  • 11
  • 15
  • 1
    The missing semicolon isn't an issue. Even if you're not fond of taking advantage of ASI, the `}` is just as effective of a statement terminator as the `;`. And the `reldataperso` does have a closing bracket. It isn't, and shouldn't be, where you think it goes. –  Feb 21 '18 at 17:22
0

You have the 'cache-control' one wrong defined, maybe it fixes it

<meta http-equiv='cache-control' content='no-cache'>

zelda11
  • 383
  • 1
  • 7