Side navigation
#12326 closed bug (invalid)
Opened August 17, 2012 06:44AM UTC
Closed August 17, 2012 07:45AM UTC
Last modified April 17, 2014 11:32PM UTC
$.AJAX changed the post content if include "??" (2 Question mark)
Reported by: | yehuicn@gmail.com | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.8.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Version: 1.7.1/1.8.0
$.ajax({ url: '/', dataType: 'json', data: '??', type: 'post', success: function(data){ }, error: function(XMLHttpRequest, textStatus, errorThrown){ } });
Please note that the post data including ?? (2 Question marks). It seems jquery change ?? as "jQuery1710291590959013191_1345184415274" (I think it is a callback name) before post to server.
The ?? was replaced on 7981th line of jquery-1.8.0.js
more information :
browser : firefox 14.0.1
OS : win7(nothing is related to OS)
THANK YOU
Attachments (0)
Change History (5)
Changed August 17, 2012 07:45AM UTC by comment:1
_comment0: | `??` is used as the callback name placeholder in the `data` for `jsonp` requests. So, finding it, jQuery will "promote" your request as `jsonp`. \ \ Two solutions here: \ * URL encode your data first using using encodeURIComponent (as it should be by default), see https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURIComponent \ * if your data is not supposed to be URL encoded, set the contentType option accordingly (for instance `"application/json"`) see http://api.jquery.com/jQuery.ajax/ → 1345189586339741 |
---|---|
resolution: | → invalid |
status: | new → closed |
Changed October 25, 2012 02:59PM UTC by comment:2
Replying to [comment:1 jaubourg]:
* if your data is not supposed to be URL encoded, set the contentType option accordingly (for instance "application/json"
) see http://api.jquery.com/jQuery.ajax/
We are setting the content type to "application/json; charset=utf-8" and the data is still being mangled:
var form = new Object(); form.p_id = '??'; $.ajax({ type: 'POST', url: ..., data: JSON.stringify( form ), processData: false, success: ..., error: ..., dataType: 'json', contentType: "application/json; charset=utf-8" });
Changed February 11, 2014 05:59PM UTC by comment:4
I've found the same thing as doherty@... above. The contentType work-around described in the bug does not work. Specifically:
if your data is not supposed to be URL encoded, set the contentType option accordingly (for instance "application/json") see http://api.jquery.com/jQuery.ajax/
That has no effect, and the ?? still causes the request to scramble the data.
The other work-around cannot be used for JSON:
URL encode your data first using encodeURIComponent (as you should by default)
So this ticket is still valid and unresolved.
Thank you.
Changed April 17, 2014 11:32PM UTC by comment:5
Yeah, I have to agree. Neither of those work arounds actually work correctly. If I wanted to have JSONP I would specify JSONP. Quick mucking with my data.
??
is used as the callback name placeholder in thedata
forjsonp
requests. So, finding it, jQuery will "promote" your request asjsonp
.Two solutions here:
"application/json"
) see http://api.jquery.com/jQuery.ajax/