Right, but using
classes you can target whatever grid cells you need. I’m telling you, you do not need to wait for all the data. If you want to that’s fine, but you don’t need to.
but even if i declare arrays for both jsons as global variable, i cannot access them outside $.getJSON
This is the difficulty/beauty of asynchronous coding. You can access them as global variables outside the AJAX call, but the problem is when you access them they probably aren’t defined yet. There are ways to handle them, but the easiest way is to put the code you need inside the callback or promise so it gets called after the AJAX call. And if you choose to wait until all the data is back, then you can chain them with nested callbacks or with then methods and put your output code in the second callback or then.
Thus i need $.when().then()
No, you don’t. You can do it that way, but you don’t need to. Again, nesting callbacks or chaining promises will do the same thing. I’m not saying your approach is bad, but that you seem to incorrectly think it is your only option.
If i do this, new problem occurs of how to incorporate $.each since i handle arrays of json requests and not single request.
Again, you can handle each request as it comes in. But you you want to create arrays of the data, you can do that too. Then you will presumably you will have two arrays. Inside your final then you can loop them and output them.