首页 > 解决方案 > how do I return a variable outside an onload function?

问题描述

request.onload = function () {
   let avg = JSON.parse(this.responseText);
};

This is my side. I have declared a global variable elsewhere. This function is supposed to update the variable so I can use the "updated" 'avg' elsewhere. Can anyone help me to return the variable outside the function?

标签: javascript

解决方案


推荐阅读