The problem is i've disabled fields too in my form, those normally are not posted, but if i use new FormData
they are.
According to the XHR and HTML5, they indeed must not be serialized. You should submit a bug against those browsers who do.
How to solve this problem? I don't need to post disabled input fields!
I you just don't need them, wait for a fix. If you require them to be omitted, you could try the following workaround:
var $form = /* whatever you have */;
var $inputs = $form.find(":disabled").each(function() {
$(this).data("xhr-name", this.name);
this.name = ""; // fields with empty names must be ignored as well
});
var formdata = new FormData($form[0]);
$inputs.each(function() {
this.name = $(this).data("xhr-name");
});
If this neither works, you could a) completely detach the inputs from the DOM and restore them later, or b) construct the FormData
manually.