Reputation: 31
I am trying to run the following code on Xampp:
const handleRequest = () => {
var xmlObject = XMLHttpRequest();
xmlObject.open("GET", "process.php", true);
xmlObject.onreadystatechange = () => {
if (xmlObject.readyState == 4 && xmlObject.status == 200) {
document.getElementById("response").innerHTML = xmlObject.responseText;
}
}
xmlObject.send();
}
Upvotes: 2
Views: 195
Reputation: 26
In order to make your code work you need to add operator "new" in front of "XMLHttpRequest()" call.
Correct code:
var xmlObject = new XMLHttpRequest();
Upvotes: 1
Reputation: 919
var xmlObject = new XMLHttpRequest();
You Need To Have The new Keyword
Upvotes: 1
Reputation: 405
You must declare your object with new
operator:
var xmlObject = new XMLHttpRequest();
Upvotes: 1