Thanks for thinking about this. However the items in the data object are being escaped automatically for me (since I have not set the processData option to false). So if I escape it, then it is double escaped on the wire.
Note that if the ? does not appear at the start of the string then it is correctly escaped and transmitted across the wire. Also, the regular expression being used to find the strings to change looks for both =? and =%3F (the escaped form). This behavior is present in the latest svn version of the code too: http://dev.jquery.com/browser/trunk/jquery/src/ajax.js -ben On Dec 4, 2:43 pm, "Scott Trudeau" <[EMAIL PROTECTED]> wrote: > ? is a reserved character in URLs (it separates the domain from the GET > parameters) and must be encoded if it's data. > > http://www.blooberry.com/indexdot/html/topics/urlencoding.htm > > Scott > > On Dec 4, 2007 2:00 PM, Ben Bennett <[EMAIL PROTECTED]> wrote: > > > > > > > This is my first post so I really should thank everyone for a > > fanatastic library. > > > However, I think I have found a bug... > > > Using jQuery 1.2.1, if I have: > > > $.ajax({ > > type: "POST", > > url: "test.html", > > dataType: "json", > > data: {query: queryString}, > > }); > > > When queryString starts with a ? it will get converted to > > jsonp1231234124... > > > This is clearly happening because of the code at line 2226 of the full > > release version: > > // Build temporary JSONP function > > if ( s.dataType == "json" && (s.data && > > s.data.match(jsre) || s.url.match(jsre)) ) { > > jsonp = "jsonp" + jsc++; > > > // Replace the =? sequence both in the query > > string and the data > > if ( s.data ) > > s.data = s.data.replace(jsre, "=" + > > jsonp); > > s.url = s.url.replace(jsre, "=" + jsonp); > > > ... > > > But I see no way to prevent that from happening. > > > Now... one might suggest that I should avoid a leading ? in my option > > names. But I am taking them from input boxes and ? is a valid thing > > for a user to type. Unfortunately there seems to be no good way to > > escape the string to prevent this behavior (without teaching the > > called code how to unescape it). > > > Also, the docs don't mention that the =? escaping happens to a json > > dataType... I see it for jsonp. > > > Is this behavior intentional? If so, there should be a way to > > suppress it or at a way for the calling code to escape the values to > > cause a leading ? to be passed to the server. > > > -ben > > -- > -- > Scott Trudeau > scott.trudeau AT gmail DOT comhttp://sstrudeau.com/ > AIM: sodthestreets