FileUpload
opened this issue · comments
Thank you for a great library!
If possible it would be great if it worked with form file ( as base 64 string).
Besides that, it would also be great if it actually returned JSON, and that it always were parsed as valid json with numbers, booleans ect, that could be as an option if one would like it to be strings...
If possible it would be great if it worked with form file ( as base 64 string).
I'm sorry but this plugin does not handle files. This is by design, because handling files in forms with JavaScript has it's own big set of problems, that are better solved by other plugins and techniques.
Remember that serializeJSON()
is based on jQuery's serializeArray()
method, that uses the standard W3C rules for successful controls to determine which elements it should include; in particular the element cannot be disabled and must contain a name attribute. No submit button value is serialized since the form was not submitted using a button. Data from file select elements is not serialized. Elements that do not contain a value attribute are represented with the empty string value.
it would also be great if it actually returned JSON
If with "actually returned JSON" you mean the formatted string, you only have to use JSON.stringify
to convert the returned object to a JSON formatted string.
and that it always were parsed as valid json with numbers, booleans ect, that could be as an option if one would like it to be strings...
Doing automatic type detection is very problematic, specially when handing inputs from users. There's no way to know if "null" or "0" are strings or not. That's why by default all values are strings. And that way, the "default" behavior is exactly the same as when you submit a regular HTML form to your server.
Interpreting value types is up to the developer. If what you need is automatic type detection, just use type :auto
in the input names, or simply use the option parseAll
:
$('form').serializeJSON({paseAll: true});