Am I Properly Using JSON Files with $.getJSON?

Am I Properly Using JSON Files with $.getJSON?

I just got introduced to JQuery and using JSON data yesterday. I'm wondering if I'm properly and efficiently using them because it's really not making sense. 

With what I have to work with, It seems like I'm grabbing entire databases worth of data EVERY time someone makes a request and processing it in the browser. That doesn't seem remotely efficient, why can't I just ask for the piece of data I need by querying the JSON file for items that match certain criteria, allowing the server to do most of the work? 

We have a site using ASP.NET (aspx files using C#, that's about all I know). 

We have numerous databases that we can access as either JSON or XML. 

The many databases are linked together with ID's, I need to be able to search each database for a specific ID and pull out all the specific information related to that ID and throw it into a multidimensional array. Can I do this without grabbing every single DB we have, loading it into the browser and manipulating it with JavaScript? Some DB's are over 2MB in size, I feel like it could get sluggish quickly. 

Here's the code I'm currently using, part of it anyway. I'm not happy with this either, why do I have to chain my $.getJSON requests together with functions? If I don't, the array's don't get built because the $.getJSON happens simultaneously as any outside methods I use to manipulate the array. 
(JQuery 1.5.1)

  1. var elem1Array = new Array();
  2. var elem2Array = new Array();


  3. function assessElem1()
  4. {
  5. $.getJSON('http://XXX.XXX.XXX.svc/TableName1?$format=json&$callback=?', 
  6. function (response) 
  7. $.each(response.d, function (index, value)
  8. {
  9. elem1Array.push(value.ID);
  10. //alert(newArray[index]);
  11. });
  12. assessElem2(elem1Array);
  13. }

  14. ); 
  15. }
  16. function assessElem2(Array1)
  17. {
  18. $.getJSON('http://XXX.XXX.XXX.svc/TableName2?$format=json&$callback=?', 
  19. function (response) 
  20. $.each(response.d, function (index, value)
  21. {
  22. elem2Array.push(value.ID);
  23. //alert(newArray[index]);
  24. });
  25. groupObjects(elem1Array,elem2Array);
  26. }

  27. ); 
  28. }

  29. function groupObject(array1,array2)
  30. {
  31.       // This function will search for matching ID #'s and create a
  32.       // multimensional array with the parent ID and the ID's of the
  33.       // matching child elements. 
  34. }
It's possible for me to create and use a .aspx file instead but I don't know much about C# or if it would be any more efficient than JQuery.