I have a situation where i have 3 multiselects, say level1,level2 and level3
now, level2 depends on the option selected in level1 and similarly level3 depends on the option selected in level2
My question is that is it better to get all the data in one go that is when the page loads and filter this data using jquery depending on the option selected by the user OR should i make ajax based request to the database to fetch the data for the next multiselect each time user selects an options.
which approach would be better??
I have a situation where i have 3 multiselects, say level1,level2 and level3 now,
Share
My answer would be that it depends on the amount of data shown.
If the amount of data in level1, level2, level3 is relatively small – you’d benefit from retrieving all the data: you’ll save the load to the server by reducing a number of requests. This will make you write some javascript, but the filling of the lists will be lightning fast.
On the other hand, if your tree has a lot of data (i.e. 100 level1 items, each one has 100 level2 items, each of which has 100 level3 items), you’ll end up in transferring a million of items (huge overhead for this usecase), and the good solution for this case is a separate AJAX call for each list.