5c0f1el9 5c0f1el9 - 2 months ago 8x
PHP Question

Ajax won't run on xampp

I am trying to run the following code on xampp :

<! DOCTYPE html>
<title>Ajax test</title>
function sendAjax() {
var xmlObject = XMLHttpRequest();
xmlObject.open("GET", "process.php", true);
xmlObject.onreadystatechange = function() {
if (xmlObject.readyState == 4 && xmlObject.status == 200) {
document.getElementById("response").innerHTML = xmlObject.responseText;
<div id="response"></div>
<input type="button" onclick="sendAjax()" value="Send Ajax Request">

Here is the process.php file content :

echo "Hello wolrd !";

On clicking on "Send Ajax Request button" the "Hello wolrd:" message is not displayed ..

Any help please ?

PS: My project folder contains two files index.php && process.php


You must declare your object with new operator:

var xmlObject = new XMLHttpRequest();