Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Ajax always processes data for requests without entity body #3438
Comments
dmethvin
referenced this issue
Dec 8, 2016
Closed
whatever the s.processData is, if s.data exist, jquery.param should execute if the data is not string for get request #3409
markelog
added
the
Ajax
label
Dec 12, 2016
markelog
added
the
Needs review
label
Dec 19, 2016
timmywil
referenced this issue
Dec 19, 2016
Closed
ajax post with contenttype="application/json" need process data to json string #3408
timmywil
removed
the
Needs review
label
Jan 16, 2017
timmywil
assigned
dmethvin
Jan 16, 2017
timmywil
added this to the 3.2.0 milestone
Jan 16, 2017
timmywil
modified the milestones:
3.2.0,
3.3.0
Mar 6, 2017
added a commit
to dmethvin/jquery
that referenced
this issue
Sep 12, 2017
dmethvin
referenced this issue
Sep 12, 2017
Closed
Ajax: Don't process data property on no-entity-body requests #3781
|
The real question is : what is the purpose of setting the The Conflating the |
|
I have a hard time imagining any plausible purpose for No matter what, though, it's clear that http://api.jquery.com/jQuery.ajax/ needs an update. |
gibson042
referenced this issue
in jquery/api.jquery.com
Sep 18, 2017
Open
Improve jQuery.ajax documentation #1061
|
I hear you but I simply can't agree with a change that will make the following code not work anymore : $.ajax( {
url: "http://my.domain/path/to/script",
data: "param1=value1¶m2=value2",
processData: false
} );There are many situations where it's far simpler to serialize url parameters beforehand rather than construct a data structure for the sole purpose of accomodating jQuery's internal serialization (hence my example of an object with a custom I think there clearly is a problem with the documentation if it implies that BTW, As an aside, where and when |
|
Hi @jaubourg! Always glad to have you here.
We do want the data to be used. One of the use cases that precipitated the ticket was that someone wanted to serialize the data to JSON rather than form-encode it.
Ok, so a prefilter that might take If the If we're not making code changes I definitely think we need to make docs changes. I'm not sure I see a lot of utility in |
|
Hi @dmethvin! Always glad to argue on tickets ;) Please note Your "don't use this" recommandation is spot on. The only time you need it is when you provide The following would definitely make $.ajaxPrefilter( options => {
options.data = options.data || options.rawData;
} ); |
dmethvin commentedDec 8, 2016
I'm creating this ticket based on the discussion in the gh-3409 PR from @Litor so we don't forget to review it.
With ajax requests using HTTP methods that do not have a request body, such as GET, any provided data is always processed and removed, even if the caller specified
processData: false. This seems contrary to the documentation which says:This behavior was also present before 3.x so it's not any kind of recent regression, but it does seem like a bug. I suppose you could argue that "this processing can be circumvented" refers only to serializing objects but not to appending the data to the URL, but that interpretation doesn't make sense. Why would someone want😸
[object Object]appended to their URL?If we didn't process
dataat all, it would be possible for abeforeSendhandler to take an object and stringify it to the URL as desired , something like this currently non-working example:http://jsbin.com/fucigaqure/edit?html,console