[英]how to access the variables in 1st API function in the 2nd API function
$.getJSON(url, function (data) {
$.getJSON(url_wind, function (data2) {
//do stuff with 'data' and 'data2'
});
});
when I use the data of the first getJSON()
in the 2nd getJSON()
there is an error saying undefined
help me please当我使用的第一个数据getJSON()
在第二getJSON()
有一个错误说undefined
请帮助我
Use the promises rather this nesting.使用承诺而不是这种嵌套。 it's easy to debug.很容易调试。
Call it like this with async await.用异步等待调用它。
(async function () {
let data = await $.getJSON(url);
let data2 = await $.getJSON(url_wind);
console.log(data, data2);
})();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.