JSON API- elimintate the global widgetResults variable?

CharlasLibraryThing API Development

Únete a LibraryThing para publicar.

JSON API- elimintate the global widgetResults variable?

Este tema está marcado actualmente como "inactivo"—el último mensaje es de hace más de 90 días. Puedes reactivarlo escribiendo una respuesta.

1davidfoley
mayo 1, 2009, 6:45 am

Hi there,

when using the JSON API I notice that you declare a global variable named widgetResults,
then you invoke the callback function, passing the response object referenced by that variable to the callback in the generated javascript response. Typically the way I use callbacks in conjunction with JSON services is to create a function per call, then to delete that callback function once it has been used.

Doing this with the LibraryThing API makes absolutely no difference, as the global variable is always declared before invoking the callback.

I really think that rather than declaring a global variable, that you should supply the json result as an object literal as the first argument to the callback.

It would keep an already cluttered global scope a little less cluttered and makes it impossible for any possiblity (which is def. an edge case) of supplying expired data to callbacks.

Just my 2 cents- love libraryThing btw!

David