Nononono. Not. Just please. not. This is not JSONP, it is javascript that executes a function with an object as a parameter that contains more javascript. Ahh!
This is JSON because it is only one object:
{ 'one': 1, 'two': 2, 'three':3 }
This is JSONP because only one object has passed through a function; if you go to http://somesite/get_some_object?jsonp=grab , the server will return:
grab({ 'one': 1, 'two': 2, 'three':3 });
This is not JSON at all. This is just Javascript:
alert("hello");
And this? Javascript code stored inside a string (ouch!) Inside an object passed to a function that should evaluate the string (but it may or may not):
grab({"body": "alert(\"Hello!\");\n"});
Look at all semicolons and backslashes! I get nightmares from this kind of thing. This is like a poorly written Lisp macro, because it is much more complicated than it should (and should!) Be. Instead, in the code, enter the grab function:
function grab(message) { alert(message.body); }
and then use JSONP to return the server:
grab({body: "Hello!"});
Do not let the server decide how to launch its web page. Instead, let your web page decide how to launch the web page, and just fill in the blanks with the server.
As for the online service that does this? I don't know anything, sorry
Michael
source share