Ah..that's a nice one. Thanks a lot! Doesnt jquery do something like this?

So I'm guessing the answer to my initial question about variable names is
No.

Shreyas

On Tue, Apr 19, 2011 at 6:45 PM, Poetro <[email protected]> wrote:

> 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]
>

-- 
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