Javascript 用Cookie日志脚本[HELP]替换3次单击后的元素

Javascript 用Cookie日志脚本[HELP]替换3次单击后的元素,javascript,html,ajax,replace,element,Javascript,Html,Ajax,Replace,Element,尝试用cookie日志记录替换单击3次后的元素。因此,Web服务器会记住某个特定元素的点击次数超过3次,并将其替换为url 1。所以这应该很简单,但是,我试着完成我的,这就是我想到的: document.getElementById("replace1").innerHTML = localStorage.getItem("replace1"); let count = 0; function loadDoc() { var xhttp = new XMLHttpRequest()

尝试用cookie日志记录替换单击3次后的元素。因此,Web服务器会记住某个特定元素的点击次数超过3次,并将其替换为url 1。所以这应该很简单,但是,我试着完成我的,这就是我想到的:

document.getElementById("replace1").innerHTML = localStorage.getItem("replace1");

let count = 0;
function loadDoc() {    
  var xhttp = new XMLHttpRequest();

  let callback = function() {
  count++;    
  if (!(count >= 3 && this.readyState == 4 && this.status == 200)) { 
     localStorage.setItem("replace1",this.responseText);   
  }
  iframe1.click(callback);    
  xhttp.open("GET", "https://natevanghacks.com/replacements/yoinkexecutor2.html", true);
  xhttp.send(); 
  }
};

正如预测的那样,由于某种原因,它不会起作用。我所要做的就是用url替换3次点击后的元素,webserver会记住更改,这样它就不会返回到默认状态。无论是在数据库中还是在Cookie、会话存储、本地存储中。

是否调用了您的函数?将调用回调