function requests() {
var request = new XMLHttpRequest();
request.open('GET', '/orders_{{name}}_{{id}}');
request.responseType = 'json';
request.send();
request.onload = function() {
var orders = request.response['orders'];
console.log(orders);
return orders;
}
}
var response = requests();
console.log(response);
第一个console.log()
打印出对象,但是第二个未定义。为什么会这样?