Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

129
Visualizações
Reading to JSON URLs with jQuery

I need to read two JSON URLs with jQuery, mangle them together and then proceed updating my UI from the JSON data.

With the two URLs in URLA and URLB and a global variable globalDataA I tried:

function useBothData(dataB) {
   // use dataB and globalDataA
};

function useDataA (data) {
    globalDataA = data
    $.getJSON (URLB, useBothData);
};

$.getJSON (URLA, useDataA);

The idea is that after loading the 1st URL I load the 2nd and then work with them. However this does never seem to return. (I get the Brwoser warning "Script takes too long".)

How can I arrange jQuery's getJSON calls for the two URLs (and their success functions), so that I can then use their data in finally one function?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can use the callback function of getJSON

$.getJSON(URLA, useDataA, function(dataB) {
  //useBothData = globalDataA + dataB

  $.getJSON(URLB, useBothData, function(result) {
    //do more stuff
  })
});
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda