This is undocumented as yet, but I just pushed it into master. I welcome any and all feedback. This is my first (second?) foray into jsonp, so there's a fair chance I'm not doing it right...
New setting: variables.framework.jsonp -- default value = false.
Change its value to a string, which will be the NAME of the request parameter (e.g. url param for GET requests) of the callback method wrapper... so given:
//This is probably the most common use, but it could just as easily be "goat"
variables.framework.jsonp = "callback";
You would receive the same result as:
... except it would be wrapped in a call to zomgdude();
Such that if the response to the former was:
{"hello":"world"}
Then the response to the latter would be:
zomgdude({"hello":"world"});
---
So please feel free to play and test, report bugs, etc. Am I doing it completely wrong? Tell me that too!
The only assumption I can think of that this implementation makes is:
- If you enable jsonp (by setting variables.framework.jsonp to anything other than false) then ANY time there's a request argument (url param or otherwise) with THAT name, the response WILL be wrapped in a callback of that name, regardless of the requested response type. This means that if your API supports BOTH XML and JSON(P) _and_ someone requests XML _and_ they specify a callback name, then they're going to get callback(xml-content)... Not ideal, but really it's their dumb fault. :P
Looking forward to your feedback!
Adam
P.S. ~ Do you think the default should be "callback" and you should have to explicitly disable it by setting it to false?