javascript - Very slow upload of form data in IE11 - Jquery/ajax -
looked @ million posts on cannot find actual solution. looking either solution or confirmation ie11 bug have deal with. trying use ajax form data post image. works in every browser other ie11 (dont care other versions of ie). no matter try post sits in pending state shown here:
sometimes finish take 100+ seconds complete, not ideal @ all.
anyone have idea how work around plugin or method of uploading images?
my code:
var inputfield = $(e.target); var rxcontainer = $(e.target).closest('.image-preview-container'); var uploadbtn = $(rxcontainer).find('.fileinput-button'); var uploadbtntxt = $(uploadbtn).find('span'); var base64text = $(rxcontainer).find('.base64text'); var imageaccesskey = $(rxcontainer).find('.accesskey-div').find('input'); var image = $(inputfield).data('image'); var blobfile = inputfield[0].files[0]; var fd = new formdata(); fd.append('file', blobfile); fd.append('nothing', 'nothing'); //disable buttons during upload $(inputfield).prop('disabled', true); $(uploadbtn).css('opacity', '0.3'); $(':submit').prop('disabled', true); $(':submit').css('opacity', '0.3'); var xhr; var uploadimage = function () { showloadingdialog(); xhr = $.ajax({ url: urls.rximageuploadapi, headers: { 'authorization': 'bearer ' + image }, type: 'post', data: fd ? fd : inputfield.serialize(), processdata: false, contenttype: false, cached: false, success: function(response) { //load image access key form imageaccesskey.val(response.imageaccesskey); //load returned image preview window loadimage(response.image, rxcontainer); $(base64text).html(response.image); //re-enable buttons after upload $(inputfield).prop('disabled', false); $(uploadbtn).css('opacity', '1'); $(':submit').prop('disabled', false); $(':submit').css('opacity', '1'); hideloadingdialog(); }, error: function(jqxhr, textstatus, errormessage) { //display error message clearcanvas(rxcontainer); uploadbtntxt.text(resources.choosephoto_message); $maxfilesizeerror.hide(); $maxfiletypeerror.hide(); if (jqxhr.status == "500") { var errorresponse = jqxhr.responsetext; var jsonresponse = json.parse(errorresponse); if (jsonresponse.errors != undefined && jsonresponse.errors.length > 0) { (var = 0; < jsonresponse.errors.length; i++) { var errortext = jsonresponse.errors[i].message; if (errortext == "blank_image" || errortext == "corrupted_file") { $corruptedfile.show(); break; } else if (errortext == "password_protected") { $passwordprotectedfile.show(); break; } } } else { $fileuploaderror.show(); } } else { $fileuploaderror.show(); } //re-enable buttons after upload $(inputfield).prop('disabled', false); $(uploadbtn).css('opacity', '1'); $(':submit').prop('disabled', false); $(':submit').css('opacity', '1'); hideloadingdialog(); } }); }
Comments
Post a Comment