I've been troubleshooting an example I created (index.html
) where a button click should change the text content of a box to 'Hello World', sourced from include.html
. The issue seems to be related to the send()
method, as indicated in the console log:
POST http://localhost:8080/include.html 405 (Method Not Allowed)
document.querySelector.onclick @ main.js:10
Below is the snippet from the main.js
file:
document.querySelector('button').onclick = function() {
var xhr = new XMLHttpRequest();
xhr.open("POST", "include.html", true);
xhr.onreadystatechange = function() {
if(this.readyState == 4 && this.status == 200) {
document.querySelector('div').innerHTML = this.responseText;
}
}
xhr.send();
}
If anyone could offer some insights or tips on resolving this issue, I would greatly appreciate it. Thank you.