首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jQuery $.get然后$.get

jQuery $.get然后$.get
EN

Stack Overflow用户
提问于 2020-10-02 21:37:04
回答 1查看 168关注 0票数 0

雏菊链$.get是如何像这样调用的:

代码语言:javascript
复制
let data1;
let data2;

$.get(data1URL).done((data) => {
  data1 = data;
  secondCall();
}).catch(error => console.log(error));

function secondCall() {
  $.get(data2URL).done((data) => {
    data2 = data;
    buildPage();
  }).catch(error => console.log(error));
}

function buildPage() {
  console.log(data1);
  console.log(data2);
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-10-02 21:49:31

您可以使用jQuery.when方法。

代码语言:javascript
复制
$.when( $.ajax( "/page1.php" ), $.ajax( "/page2.php" ) )
  .then( myFunc, myFailure );

https://api.jquery.com/jquery.when/

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64178522

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档