-
Notifications
You must be signed in to change notification settings - Fork 266
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
jQuery.ajax: Document special handling of a double question mark #1171
Conversation
BTW, is it just the double question mark? Isn't the single one replaced as well? |
From the code it seems that /(=)\?(?=&|$)|\?\?/ See the visualization at: |
entries/jQuery.ajax.xml
Outdated
<desc> | ||
<p>Data to be sent to the server. If the HTTP method is one that cannot have an entity body, such as GET, the <code>data</code> is appended to the URL.</p> | ||
<p>When <code>data</code> is an object, jQuery generates the data string from the object's key/value pairs unless the <code>processData</code> option is set to <code>false</code>. For example, <code>{ a: "bc", d: "e,f" }</code> is converted to the string <code>"a=bc&d=e%2Cf"</code>. If the value is an array, jQuery serializes multiple values with same key based on the value of the <code>traditional</code> setting (described below). For example, <code>{ a: [1,2] }</code> becomes the string <code>"a%5B%5D=1&a%5B%5D=2"</code> with the default <code>traditional: false</code> setting.</p> | ||
<p>When <code>data</code> is passed as a string it should <strong>already be encoded</strong> using the correct encoding for <code>contentType</code>, which by default is <code>application/x-www-form-urlencoded</code>. If the string contains a double question mark (<code>??</code>) it is replaced with a value generated by jQuery that is unique for each copy of the library on the page (e.g. <code>jQuery21406515378922229067_1479880736745</code>).</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should document it only happens for dataType: "jsonp"
or dataType: "json"
and the latter will no longer trigger it in jQuery 4.0+.
We also need to take jquery/jquery#4754 into account - in jQuery 4 the logic will only be triggered for requests with |
Fixes jquerygh-999 Ref jquerygh-1005 Co-authored-by: Dave Methvin <[email protected]>
I created the issue for jQuery 4.0: #1176. |
0c831b9
to
493d13b
Compare
@timmywil I rebased the PR & added a new fixup commit with the changes from my comments. |
This is the text provided by @dmethvin in #1005 (comment) that I formatted & split into 3 paragraphs.
Fixes gh-999
Ref gh-1005
Co-authored-by: Dave Methvin [email protected]