php - JavaScript responseText not being saved as varaible? -
this question has answer here:
i using ajax run php script within site. set js variable response php script.
this script should make variable "stopat" set 42.
here error: 
here 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 gennum.php:
<?php echo json_encode(42); ?> thanks! guys can solve problem! :)
stopat local variable. defined inside function. need move statement use function.
oreq.onload = function() { var stopat = (this.responsetext); thewheel.animation.stopangle = stopat; };
Comments
Post a Comment