Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#12326 closed bug (invalid)

$.AJAX changed the post content if include "??" (2 Question mark)

Reported by: [email protected] Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.0
Keywords: Cc:
Blocked by: Blocking:


Version: 1.7.1/1.8.0

                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)


Change History (5)

comment:1 Changed 10 years ago by jaubourg

Resolution: invalid
Status: newclosed

?? 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:

Last edited 10 years ago by jaubourg (previous) (diff)

comment:2 in reply to:  1 Changed 10 years ago by [email protected]

Replying to jaubourg:

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 = '??';

        type: 'POST',
        url: ...,
        data: JSON.stringify( form ),
        processData: false,
        success: ...,
        error: ...,
        dataType: 'json',
        contentType: "application/json; charset=utf-8"

comment:3 Changed 10 years ago by timmywil

#12878 is a duplicate of this ticket.

comment:4 Changed 9 years ago by [email protected]

I've found the same thing as [email protected] 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.

comment:5 Changed 9 years ago by [email protected]

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.

Note: See TracTickets for help on using tickets.