Quote:
xrequest.send(null);
console.log(json);
The
XMLHttpRequest.send()[
^] method returns
immediately. It does not wait until the response has been received.
The
json
variable is not assigned until the response has been received. Therefore, the
json
variable is still
undefined
in your call to
console.log
.
You need to re-think what you're doing.