问题描述:

when I added new dropdown to my view. This dropdown is filled with list from model. Model is loaded in Index action with high ammount of rows oround 4k. Problem is now that when I run the page, it freeze for like 5 seconds, before dropdown is filled, I mean my whole website is not responding. What can I do?

网友答案:

Either you can fill you drop down using ajax call after your page is loaded and show any small progress bar over the drop down while drop down is being loaded.

You will have to create an another action method that will only return the drop down element. and on document ready you will have to make an ajax call to that action method and on the success of ajax call load drop down items in drop down. :

$(document).ready(function(){
   $.ajax({
                url: //Url to your action method along with the student name in query string,
                type:get,
                dataType: "json",
                complete: function() {
                    //remove progress bar.
                },
                beforeSend: function() {
                    //Show progress bar.
                },
                success: function (data) {
                    //fill second drop down like:
                    //$("#secondDropDown").append('<option value="' + anyvalue + '">' + anyText + '</option>');
                }
            });
});
相关阅读:
Top