jQuery Form Plugin - File Upload - Different results in IE and Firefox
Posted this question a few hours ago on StackOverflow:
http://stackoverflow.com/questions/3824519/xmlhttprequest-different-in-ie8-vs-firefox-chrome
Now I found myself looking through the code of jquery.form.js for version 2.47, and found this:
function fileUpload() {
var form = $form[0];
if ($(':input[name=submit],:input[id=submit]', form).length) {
// if there is an input with a name or id of 'submit' then we won't be
// able to invoke the submit fn on the form (at least not x-browser)
alert('Error: Form elements must not have name or id of "submit".');
return;
}
var s = $.extend(true, {}, $.ajaxSettings, options);
s.context = s.context || s;
var id = 'jqFormIO' + (new Date().getTime()), fn = '_' + id;
window[fn] = function () {
var f = $io.data('form-plugin-onload');
if (f) {
f();
window[fn] = undefined;
try { delete window[fn]; } catch (e) { }
}
}
var $io = $('<iframe id="' + id + '" name="' + id + '" src="' + s.iframeSrc + '" onload="window[\'_\'+this.id]()" />');
var io = $io[0];
$io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
var xhr = { // mock object
aborted: 0,
responseText: null,
responseXML: null,
status: 0,
statusText: 'n/a',
getAllResponseHeaders: function () { },
getResponseHeader: function () { },
setRequestHeader: function () { },
abort: function () {
this.aborted = 1;
$io.attr('src', s.iframeSrc); // abort op in progress
}
};
So IE is only getting the mock object, while Firefox is interpreting the returned response properly. Why?