Disclaimer : I'm not super proficient in Javascript and there's this small JS code part in my .net program.
I have 2 dropdown lists, ReportList and YearList. The first one's selected value dynamically populates the second dropdown list using AJAX. The problem is, each time a ReportList is selected it makes a query to a database. There can be at least 200 entries in ReportList and when a user uses the mousewheel on the dropdownlist, the application, as is, makes hundreds of query in a short amount of time and crashes the database. So far I have this
$('#ReportList').change(function () {
setTimeout(function () { PopulateYearsDropdownList() }, 2000);
});
I've played with stopPropagation() and it didn't work. I can't test it very efficiently since even the test DB is hosted and maintained by someone else.
I'd like to be able to scroll through without prompting as much queries as the amount of reports that have gone through. I was thinking of adding a small delay, with each function ".change" cancelling the last function call.
I think this wasn't really thought through from the beginning, but I want to fix this in the small amount of time I have.