Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for ajax does not mention FormData #1234

Open
viktordick opened this issue Jun 25, 2023 · 4 comments
Open

Documentation for ajax does not mention FormData #1234

viktordick opened this issue Jun 25, 2023 · 4 comments
Milestone

Comments

@viktordick
Copy link

It took me quite a while to find how to create an AJAX request with a fixed ordering of transferred arguments (even if the same name occurs multiple times) with a multipart/form-data encoding. I ended up posting a question to StackOverflow (https://stackoverflow.com/q/76545035/2240052) and found a related question with an answer that makes use of the following undocumented behavior of $.ajax:

  • The data parameter can be a FormData object
  • Setting contentType to false will in this case automatically create a correct contentType header including a boundary specification

This allowed me to solve my problem, but the documentation does not mention it and could be improved.

@mgol
Copy link
Member

mgol commented Jun 27, 2023

We added explicit support for binary AJAX data in jquery/jquery#4150 which will ship with jQuery 4.0. But yes, for FormData specifically, you can make it work in 3.x by disabling contentType & processData options (which jQuery 4.x will do by default).

I agree it's worth documenting this. If you'd like to try, the AJAX page exists at https://github.com/jquery/api.jquery.com/blob/main/entries/jQuery.ajax.xml

@mgol mgol added this to the 4.0.0 milestone Jun 27, 2023
@viktordick
Copy link
Author

Somehow, any link to the CLA I found redirects to the OpenJS Foundation website or to https://openjsf.org/about/the-openjs-foundation-cla/, which still does not contain the actual content of the CLA.

Anyhow, I am not sure if I will get around to this anytime soon, but if I find a quiet hour or so I might try to give it a go to write a starting point.

@viktordick
Copy link
Author

But in any case thank you for the info about the changes for 4.x regarding this. Reading the discussion there and the referenced PR made me understand this a bit better.

@mgol
Copy link
Member

mgol commented Jun 30, 2023

The page you linked to, https://openjsf.org/about/the-openjs-foundation-cla/, contains links to CLA for individual contributors, and a CLA for corporate contributors. Those are the documents you're looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants