I am having an issue when a large amount of items (3638 to be exact) is returned IE 11 freezes up for a few seconds and then will return the list for less than a second, and then the list will go away.

I am also having issues sometimes with the breakpoint being hit inside the JsonResult method that is hooked up to the jquery autocomplete textbox.

Is there something I am missing? This all works fine in FireFox but the users will mostly have IE 11 on their computers.

Code:

        public JsonResult GetParts(string partNumber)
    {
        List<string> partNumbers = null;
        partNumber = partNumber != null ? partNumber.ToUpper() : partNumber;

        List<string> allPartsForAjaxAutoCompleteSearch = TempData.ContainsKey("allPartsForAjaxAutoCompleteSearch") ? 
            (List<string>)TempData["allPartsForAjaxAutoCompleteSearch"] : null;

        char? ajaxAutoCompleteSearchChar = TempData.ContainsKey("allPartsForAjaxAutoCompleteSearch") ?
            (char?)TempData["ajaxAutoCompleteSearchChar"] : null;

        if (ajaxAutoCompleteSearchChar != null && ajaxAutoCompleteSearchChar.Equals(partNumber[0]))
        {
            if (allPartsForAjaxAutoCompleteSearch != null)
            {
                partNumbers = allPartsForAjaxAutoCompleteSearch.Where(x => x.ToUpper().StartsWith(partNumber))
                              .Select(y => y).ToList();
            }
        }
        else
        {
            allPartsForAjaxAutoCompleteSearch = _partsOrderEntryBL.BusinessLayerPartSearch.getAllPartsForAjaxLoader(partNumber[0]);
            partNumbers = allPartsForAjaxAutoCompleteSearch.Where(x => x.ToUpper().StartsWith(partNumber))
                          .Select(y => y).ToList();
        }

        TempData["allPartsForAjaxAutoCompleteSearch"] = allPartsForAjaxAutoCompleteSearch;
        TempData["ajaxAutoCompleteSearchChar"] = partNumber[0];
        return Json(partNumbers, JsonRequestBehavior.AllowGet);
    }

Script:

          $(function () {
              var src = '@Url.Action("GetParts", "PartsShopping")'
              $("#autoCompletePartNumBox").autocomplete({
                  source: function (request, response) {
                      $.ajax({
                          url: src,
                          dataType: "json",
                          data: {
                              partNumber: $("#autoCompletePartNumBox").val()
                          },
                          success: function (data) {
                              response(data);
                          }
                      });
                  }
              });
              $("#autoCompletePartNumBox").autocomplete({ delay: 0 });
          });

Related posts

Recent Viewed