Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!