I run into problems to pass a javascript object context into the callback handler of a JSONP ajax request, when the ajax provider predefines its callback. (Flickr is the ser
Just leave the jsonpCallback
property alone, and let jQuery create the function that gets called and it's function name. That function will call the success callback that you specify, with the context you specify.
function Person(anId) {
this.name;
this.id = anId;
this.loadName = function() {
$.ajax({
url: "jsonp.json",
dataType: "jsonp",
data : {id: this.id},
context: this,
success: function (data) {
this.name = data.name;
}
});
}
}
var a = new Person(234);
a.loadName();
var b = new Person(345);
b.loadName();