Skip to content

Commit

Permalink
Fixed a non-unique JSONP callback issue
Browse files Browse the repository at this point in the history
  • Loading branch information
clifff committed Dec 15, 2010
1 parent 0ed41c7 commit e2109c4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lastfm.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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). */
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e2109c4

Please sign in to comment.