gfgdfds
gfgdfds

Reputation: 31

Ajax is not running properly with XAMPP

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

Answers (3)

Marko
Marko

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

var xmlObject = new XMLHttpRequest();

You Need To Have The new Keyword

Upvotes: 1

jaro1989
jaro1989

Reputation: 405

You must declare your object with new operator:

var xmlObject = new XMLHttpRequest();

Upvotes: 1

Related Questions