I am using a small javascript to update a text on a website by reading the content from a text file on the server. While the code itself does what I expect, I'd like to check whether the contents have changed, instead of overwriting it every 20 seconds (which restarts the marquee of course).
var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("kuechempd").innerHTML =
      "<marquee scrolldelay=50 scrollamount=2 width=140px>"+this.responseText+"</marquee>";
    }
  };
  xhttp.open("GET", "/sensorvalues/kueche_mpd.txt", true);
  xhttp.send();
I am a real noob with javascript, typically I would use a temporary variable to compare the contents like
if old <> new then
old=new
do_update
fi
But i dont know whether thats possible with javascript
Thank you in advance for any hints ;-)
 
    