Greetings. The project uses several json data files, and I need to download all the files. But I encountered a difficulty: in jQuery, the loading event runs separately for each file:

var jdata = $.getJSON('/assets/json/txg_templates.json', function() { $jdataSuccess = true; }); var boxSizing = $.getJSON('/assets/json/txg_resize.json', function() { $boxSizingSuccess = true; }); 

I tried to make a test loop on the values ​​of Boolean variables from the example, but this method, for some reason I do not work, is unstable. Is there any other way to load json massively with the download completion event?

  • "it is unstable"? - Igor
  • @Igor Does not load json and the boolean remains false - Happy_Cougar

1 answer 1

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

 $.when(jdata, boxSizing).done(function(){ console.log($jdataSuccess && $boxSizingSuccess); });)