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>
2.1m questions
2.1m answers
60 comments
57.0k users