Is it possible to specify our specific context in callback of a jsonp Ajax call?
The only way I found to do that is specifying the callback name but not implementing it so the callback go in the success method with the desired context:
$.ajax({
type: "GET",
url: 'someurl',
dataType: 'jsonp',
jsonpCallback: 'myCallbackName',
context: this,
success: function (response) {
console.log(this); //this must be the context specified earlier
}
});
The problem is that even if it's working, I receive a lot of errors:
TypeError: myCallbackName is not a function
Any idea of how to achieve this without causing errors?
Thanks
Etienne