JangoSteve / remotipart

Rails jQuery file uploads via standard Rails "remote: true" forms.
http://os.alfajango.com/remotipart
Other
1k stars 215 forks source link

ajax:success xhr strange behaviour #112

Open ghost opened 10 years ago

ghost commented 10 years ago

Guys read this piece of javascript:

$("form").bind("ajax:success", function(e, data, status, xhr) {
  $('#form-container').html(data);
  $('.message').html(xhr.getResponseHeader('X-Message'));
});

Pretty simple, lets go through the problem:

  1. This code works perfectly when i save a record using ajax and i'm NOT triggering remotipart. I can read the X-Message in the header. It works perfectly.
  2. If remotipart is triggered, the xhr.getResponseHeader('X-Message') returns null, in fact, it returns null all the headers i try to read but if i check them in chrome, the headers ARE there.
  3. The xhr object exists in both responses, but ONLY in remotipart response i can't read the headers.

Someone knows how or where can i look to fix it? I'm doing something wrong? I need help!

e-fisher commented 8 years ago

Same problem here, did anyone find a solution?

qw4n7y commented 8 years ago

Seems there is no access to response headers while using iframe ajax transport: https://github.com/JangoSteve/remotipart/blob/master/vendor/assets/javascripts/jquery.iframe-transport.js#L47