There is a code for ui-autocomplete, defined in $(function() {} :
$("#accountValue").autocomplete({ minLength: 0, source: function(request, response) { $.ajax({ url: '@Url.Action("GetAccountNumbers", "Diary")', type: "get", dataType: "json", data: { filter: request.term }, success: function(data) { response(data); } }); } }).focus(function() { $(this).autocomplete("search", ""); }); $(".ui-autocomplete").css({ "max-height": "300px", "max-width": "260px", "box-sizing": "border-box", "-ms-box-sizing": "content-box", "-moz-box-sizing": "border-box", "-webkit-box-sizing": "border-box", "overflow": "auto" }); Handler Method:
[HttpGet] public JsonResult GetAccountNumbers(string filter) { var result = new List<string>(); try { var sessionHelper = new SessionHelper(this.HttpContext); result = sessionHelper.AccountNumbers.Where(item => !string.IsNullOrEmpty(item) && item.ToLower().StartsWith(filter.ToLower())).ToList(); } catch (Exception exception) { } return Json(result, JsonRequestBehavior.AllowGet); } The handler method returns a large number of records (about 24 thousand), which greatly slows down the script. How can I increase the speed? Maybe dynamic data loading? Or from the server to give parts? Tell me, please, how to do this?
Update!
On the server, the data gets quickly. Brakes, because there are many calls to the handler method. (thanks to @teo van kot for the tip). The question is how not to pull the method so often.