Reputation: 5143
I'm getting data from a remote server, that can produce JSONP but needs the callback-function name in a non-standard way.
For code structure & simpler error-handling, I'd prefer to use the default function. Is there a way for me to get the autogenerated function name, and give that as a data-parameter?
What I'd like to be able to do is something in the lines of:
$.ajax("http://mydomain.com/xxx",
{
dataType: "jsonp",
type : 'GET',
success : function(response) {
doSomething(response);
},
data: {
format_options : 'callback:' + jQueryAutoGeneratedCallbackFunction,
outputFormat : 'json'
}
}
);
Is this possible?
Upvotes: 0
Views: 664
Reputation: 5143
..So it turns out I thinking it from a wrong angle. The answer is, that I can change the "callback"-parameter like this.
$.ajax("http://mydomain.com/xxx",
{
dataType: "jsonp",
jsonp: "format_options",
jsonpCallback:"callback:myFunction",
type : "GET",
success : function(response) {
doSomething(response);
},
data: {
foo : "bar"
}
}
);
Just as clarification, the "callback:"-part in "callback:myFunction" is needed just for the API i'm using, I included it here as i'd included it in the question.
Upvotes: 1