I did this, as well as several thousand records. Problems:
itβs difficult for the end user to navigate the list if there are hundreds of cities to choose
drop down lists because they are terrible for such things
querying the database for information is stressful because the query is basically the same, with the same results that almost never change.
So, to the solutions:
I was still standing at the dropdowns, but I added (via the UI) options for users to filter the list a bit. I will not publish the code or the layout, if you are ok with the drop-down lists as they are, keep them.
I downloaded all countries, cities and areas through JS once. Now, why - firstly, the point was not that the deal was huge, it was about 20 kilobytes gzipped, if I'm not mistaken. I didnβt want "please select a country"> "please wait, load the city"> "select a city"> "Wait, load the area"> "select the area", I absolutely hate it, I want someone to wait if they donβt need :) Thus, the whole structure is loaded immediately (when the page is requested) and stored inside the object. If the browser supports sessionStorage , I check to see if I have the object there first - if not, I load it through jQuery $ .ajax call. On the web server, the returned JSON script object actually loads the data from Memcache. If there is no entry in Memcache, I request db and download all the data, and I store it with Memcache for future reference.
Now, what happens, I have a JS object representing all countries, cities and regions - with relationships, that is, I can display the drop-down lists in some way, showing only the relevant cities for the current country selection.
Now, since you have a similar structure, you can apply the same logic. Load the item when the page loads, but check for sessionStorage . If yes, check if you have an object. Not? Make a call to $ .ajax and get it. When the popup windows fire the change event, print the appropriate data.
Hope this helps a little, I type it in a hurry :)
source share