There was a problem sending big data to the server. I do not know what to do anymore. When sending small files - everything goes almost unnoticed. When sending large files, the browser starts to hang. The file will be sent, but it is impossible to work in the browser during sending.
I understand the reason. Sending a file occurs in the main thread. Tell me please. How can I make it so that when sending large files the browser does not slow down its work at least on other sites.
function UploadFileIntoFileManager(button_obj, form_obj) { // https://incode.pro/jquery/ajax-na-praktike-progress-bar-indikator-protsessa-zagruzki.html CreateGeneralLoadingModalBox('Файловое хранилище', 'Подождите, идет загрузка файла...<br>Загружено 0%'); OpenGeneralLoadingModalBox(); var file_data = $('#file-upload').prop('files')[0]; var form_data = new FormData(); form_data.append('action', 'UploadFileIntoFileManager'); form_data.append('file', file_data); $(form_obj).find('input[type=file]').prop('value', ''); // Очистка данных по файлу в кнопке var LastPercent = 0; $.ajax({ type: form_obj.getAttribute('method'), url: form_obj.getAttribute('action'), dataType: 'text', cache: false, contentType: false, processData: false, data: form_data, beforeSend:function() { }, xhr: function(){ var xhr = $.ajaxSettings.xhr(); // получаем объект XMLHttpRequest xhr.upload.addEventListener('progress', function(evt){ // добавляем обработчик события progress (onprogress) if(evt.lengthComputable) { // если известно количество байт // высчитываем процент загруженного var percentComplete = Math.ceil(evt.loaded / evt.total * 100); // устанавливаем значение в атрибут value тега <progress> // и это же значение альтернативным текстом для браузеров, не поддерживающих <progress> $('.exit-but, .ex').click( function(){ CloseAndDestroyGeneralLoadingModalBox(true); xhr.abort(); return false; }); if(LastPercent !== percentComplete) { LastPercent = percentComplete; UpdateGeneralLoadingModalBoxContentTitle('Подождите, идет загрузка файла...<br>Загружено '+percentComplete+'%'); } } }, false); return xhr; }, success:function(data) { CloseAndDestroyGeneralLoadingModalBox(true); /*if(data['ReturnCode'] === false) { CreateGeneralFalseModalBox('Файловое хранилище', 'Возникла ошибка', data['ReturnMessage'], 'ок'); OpenGeneralFalseModalBox(); return false; } else if(data['ReturnCode'] === true) { document.location.reload(true); return true; }*/ }, error:function (xhr, ajaxOptions, thrownError) { CloseAndDestroyGeneralLoadingModalBox(true); CreateGeneralFalseModalBox('Файловое хранилище','Сервер не отвечает','Пожалуйста, попробуйте позже','ок'); OpenGeneralFalseModalBox(); return false; } }); }