jquery - Xhr request disables other AJAX requests -


so noticed bug on site testing tonight. happens on image page, , page works fine , can change status of images (primary or secondary) , delete them, navigate around other pages, etc.

so part navigate around (basically, grabs current page, requested page, , whatever formdata specific page, validated server-side)

... var formdata = $("#eventform").serializearray(); //testing bit xhr happens here (explained later) $.ajax({     url: "pagetemplates/createevent.php",     type: "post",     data: {page:page,formdata:formdata},     cache:false,     success: function(result) {         $(".account-data").html(result);     } }) ... 

but once upload image can't navigate other pages. image upload bit here:

...  var imgdata = new formdata(); $.ajaxsetup({     data:{type:type} }) imgdata.append('imagefile',$("#imagefile")[0].files[0]); $.ajax({     url: "pagetemplates/imageupload.php",     type: "post",     xhr: function() {         myxhr = $.ajaxsettings.xhr();         return myxhr;     },     data: imgdata,     cache: false,     contenttype: false,     processdata: false,     success: function(result) {         $("#imagesdata").append(result);         $("#imagefile").html("<input type='file' name='imagefile' id='imagefile' onchange='imageupdate(this)' />");     } }); ... 

i've managed trace issue down setting xhr, , testing xhr shows still exists after image upload has occurred.

is there way me disable xhr after image upload has occurred? or way unset it? or there entirely different way should handling this?

okay, figured out. realized mirrored image upload working fine elsewhere. copied/pasted code , altered form index , worked.

so this:

var imgdata = new formdata(); $.ajaxsetup({     data:{type:type} }) imgdata.append('imagefile',$("#imagefile")[0].files[0]); 

got changed into:

var formdata = new formdata($("form")[1]); 

which going more difficult maintain in ways, easier maintain in others.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -