Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
160 views
in Technique[技术] by (71.8m points)

javascript - Google Chrome XHttp request cancelled

Can anyone please help me to understand, why chrome is canceling my Xhttp request?

Code:

<!DOCTYPE html>
<html lang="en">

<head sam-include="http://localhost/Custom/Components/head.htm">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div sam-include="http://localhost/Custom/Components/brand.htm">abcd</div>
</body>
<script>
  var x = document.querySelectorAll("[sam-include]");
  if (x) {
    var SAM_Request = new XMLHttpRequest();
    for (var i = 0; i < x.length; i++) {
      var temp = x[i];
      console.log(temp);
      SAM_Request.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200)
          temp.innerHTML += this.responseText;
      };
      SAM_Request.open('GET', temp.getAttribute('sam-include'), true);
      SAM_Request.send();
      console.log(temp);
    }
  }
</script>

</html>
question from:https://stackoverflow.com/questions/65951617/google-chrome-xhttp-request-cancelled

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...