blueimp/jQuery-File-Upload — Issue #837: Browser compatibility nightmare
Author: josegrad
Created: 2011-12-04 09:05:02+00:00
State: open

Hi, I'm trying to get the plugin working on as many browsers as possible.
I'm using the basic setup and defining the UI myself.

I'm on Rails 3.0.x and I pre-save a picture so I can offer preview for a picture upload process. So I save the picture, return the location from the server side and then the user keeps filling a form that gets finally submitted, including the image location.

Everything is ok with browsers that support XHR upload. For those I return json from the server and it gets processed fine.

For the browsers that do not support XHR upload I return text/plain as adviced. Here's where my problems start.
This is how I decide at client side from where to extract the image location;

if(data.dataType === "iframe ") {
var pre_save_response = data.result[0].body.innerText
... then do whatever with the image info ...

The issue I find is that the information the server returns (a url in this case) is not always in the innerText element.
Depending on the browser it might be in the ..body.textResult, or ..body.outerText
So it is a bit hacky to handle all the variations. This makes me wonder if I'm following the right approach.

Another nasty thing is that error situations come back to the non XHR support browsers via the "done" callback even though the server returns a 500 status code. They do not return over the "fail" callback like when I reply with json content type.

I'm using the latest release of the plugin since yesterday. But the code is the same I used for 5.0.3 release.
Here's a pastie of the main js for the client side: http://pastie.org/2963500

Any advices how to simplify this? Is this the right approach?