2011/4/19 Shreyas Subramaniam <[email protected]>:
> Thats how I would do it for a regular AJAX call...but I am looking to make a
> JSONP call. Thats where the problem arises.
>

Create unique functions... for example:

var generateFunction = (function (window) {
  var uid = 0;

  return function (instance, callback) {
    var name;
    uid += 1;
    name = 'jsonpCallback' + uid
    window[name] = function () {
      callback.call(instance)
      delete window[name];
    }
    return name;
  }
}(window));

Usage:
var myObj = {},
    callbackName = generateFunction(myobj, function () { console.log(this) });
callJSONP(url, callbackName);

-- 
Poetro

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to