0
如何在socket.onmessage函数中设置var响应。 var响应未发现,但我已经设置了该函数。但我需要响应变量,因为我的函数结束时有回调。关闭时设置变量
function getVariables_Groups(_callback) {
var self = this;
var response = {};
socket.onmessage = function(evt) {
json = JSON.parse(JSON.parse(evt.data));
var statistics = {};
var groups = json.args;
statistics.action = "internal_dashboard_statistics";
if(groups[0] == "notfound") {
statistics.args[0] = "notfound";
loadVariable("dashboard.htm", statistics);
} else {
statistics.args = [];
for(var i = 0; i < json.args.length; i++) {
statistics.args[i] = {};
statistics.args[i].name = groups[i];
}
console.log(statistics);
self.response = statistics;
}
}
console.log(response);
_callback(response);
}
欢迎来到** async **的精彩世界!你不能那样做。 – SLaks