dan_l
dan_l

Reputation: 1692

using Mozilla FormData with jquery $.ajax call

I am using html5 to allow allow drag and drop of files , and submit form data along with files in a multipart/form-data request with the mozilla FormData() api ( there is a append() function for a FormData object and I append values and files with it ). I use the jQuery.ajax() and set the data to the FormData object I created and set the processData flag to false, and contentType to "multipart/form-data" , with a beforeSend handler call jqXHR.setReqeustHeader("Conetent-Type", "multipart/form-data") again . But in the firebug I can see that request header is still having Content-Type: text/html .

It seems $.ajax() ignore my content type specification . Has anyone else successfually using jQuery.ajax() to work with FormData api of html5 ?

I know that I can make my own XMLHttpReqeust without help of jquery , and it works too . But I like a unified framework such as jquery.

Upvotes: 0

Views: 1268

Answers (1)

Vladimir Prudnikov
Vladimir Prudnikov

Reputation: 7232

You should set contentType to false instead of real content type. Also set processData to false. Here is more details.

Upvotes: 1

Related Questions