I'm playing around a little with Ajax and i'm using the following code.
var r = new XMLHttpRequest();
r.open("POST", "pythonTesting.php", true);
r.onreadystatechange = function () {
if (r.readyState === 4 && r.status === 200) {
alert("Success: " + r.responseText);
}
};
r.send("text=yellow");
It is successful but the alert isn't showing the actual responseText
.
pythonTesting.php (not to be confused by the name) is just:
<?php
echo $_POST['text'];
?>
I'm expecting the responseText
to be yellow
because that's how I sent it but its not. I'm not really seeing what the problem is though. It must be one of those easy to fix mistakes.