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

Reply via email to