jQuery uses the encodeURI()
, so the data sent through AJAX is like this:
key1=true & key2=34 & ...
To send an image through AJAX, I use the FormData()
, so the data from AJAX (without an image) is like:
-----------------------------7e136023611f0
Content-Disposition: form-data; name="key2"
34
Now I have two pure-JS functions for AJAX. The main one uses encodeURI()
, and the other one is only for uploading images, using the new FormData()
.
As I want to have only one AJAX function, my question is - would it be reasonable so switch only to the FormData()
? What's the reason for jQuery to use the encodeURI()
?