kosnkov
kosnkov

Reputation: 5941

MVC freeze, page is not responding for few seconds

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?

Upvotes: 0

Views: 891

Answers (1)

Hassan Baig
Hassan Baig

Reputation: 346

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>');
                }
            });
});

Upvotes: 1

Related Questions