[英]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'
});
});
當我使用的第一個數據getJSON()
在第二getJSON()
有一個錯誤說undefined
請幫助我
使用承諾而不是這種嵌套。 很容易調試。
用異步等待調用它。
(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.