From e2109c40048643ce5a814596768199bad9948d2d Mon Sep 17 00:00:00 2001 From: Clif Reeder Date: Wed, 15 Dec 2010 11:46:57 -0500 Subject: [PATCH] Fixed a non-unique JSONP callback issue --- lastfm.api.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lastfm.api.js b/lastfm.api.js index e831b69..b082218 100644 --- a/lastfm.api.js +++ b/lastfm.api.js @@ -31,6 +31,9 @@ function LastFM(options){ cache = _cache; }; + /* Set the JSONP callback identifier counter. This is used to ensure the callbacks are unique */ + var jsonpCounter = 0; + /* Internal call (POST, GET). */ var internalCall = function(params, callbacks, requestMethod){ /* Cross-domain POST request (doesn't return any data, always successful). */ @@ -90,7 +93,10 @@ function LastFM(options){ /* Cross-domain GET request (JSONP). */ else{ /* Get JSONP callback name. */ - var jsonp = 'jsonp' + new Date().getTime(); + var jsonp = 'jsonp' + new Date().getTime() + jsonpCounter; + + /* Update the unique JSONP callback counter */ + jsonpCounter += 1; /* Calculate cache hash. */ var hash = auth.getApiSignature(params);