I am using Ajax to run a PHP script within my site. I would like to set a JS variable to the response from the PHP script.
This script should make the variable "stopAt" set to 42.
Here is my error:
Here is my code:
function reqListener () {
console.log(this.responseText);
}
var oReq = new XMLHttpRequest(); //New request object
oReq.onload = function() {
var stopAt = (this.responseText)
};
oReq.open("get", "gennum.php", true);
oReq.send();
theWheel.animation.stopAngle = stopAt;
Here is gennum.php:
<?php
echo json_encode(42);
?>
Thanks! Hopefully you guys can solve my problem! :)