jQuery does this automatically if you use their JSONP ajax function.
In the past, I've just pushed callbacks onto an array.  The JSONP
callback parameter
can then be:

    ?callback=myCallbacks[123]

this will generate:

    myCallbacks[123]({...JSONP result...});

On Apr 15, 1:22 am, Shreyas Subramaniam
<[email protected]> wrote:
>  I was wondering if it is possible in any way to programatically get the
> name of a javascript variable (as a string)? The reason I ask is, that I
> have a class, with multiple instances, and each instance needs to make a
> jsonp call, and the callback function has to be called on the instance which
> made the jsonp call.
>
> var foo = function() {
> //some class
>
> }
>
> foo.prototype.makeJSONPCall = function() {
>
> }
>
> foo.prototype.responseHandler = function(str) {
> this.value = str;
>
> }
>
> var a = new foo();
> var b = new foo();
> var c = new foo();
>
> So, a.responseHandler needs to be the callback fn for a.makeJSONPCall. I
> know this behavior can be achieved in other ways(by pushing instances into
> an array), but was wondering if any of you have come up with a better way to
> achieve this.
>
> Thanks!
>
> Shreyas Subramaniam

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