score:1

Accepted answer

It is good idea to store your data into array but not good for those which are having big data.

As you mentioned that on click event you get the new record of the selected state so it is better to store the record in the array as a second key record i mean

array[0] = "Parent record"
array[1] = "Child Record"
array[2] = "Sub Child Record"

So by this you can get record on the spot no need to loop over json now when you come back as you mentioned suppose from state to country than just reload the page by

document.location.reload()

so your array will be initialized with the null values so you can store new values by going to different state no need to get record from country and set because country would be your main page.


Related Query