I like passing query string params to $.getJSON as an array using the
optional data argument because it's more readable. However when using
a jsonp callback parameter it gets encoded to callback=%3F, causing it
to fail. Any way to accomplish this without modifying jquery?
This patch to jquery made it work:
--- jquery-1.3.2.js.orig 2009-02-19 18:02:00.000000000 -0500
+++ jquery-1.3.2.js 2009-07-17 20:21:30.000000000 -0400
@@ -3403,8 +3403,11 @@
type = s.type.toUpperCase();
// convert data if not already a string
- if ( s.data && s.processData && typeof s.data !== "string" )
+ if ( s.data && s.processData && typeof s.data !== "string" ) {
s.data = jQuery.param(s.data);
+ // reverse encoding of jsonp callback param
+ s.data = s.data.replace(/callback=%3F$/, "callback=?");
+ }
// Handle JSONP Parameter Callbacks
if ( s.dataType == "jsonp" ) {