Skip to content
Browse files

Fixing callback generation/cleanup bug in JSONP functionality.

  • Loading branch information...
1 parent d8984e3 commit 8f9df4faaf4416d3805529427de592d97a34544c @jcoglan jcoglan committed with beastaugh Jul 11, 2009
Showing with 7 additions and 4 deletions.
  1. +7 −4 source/packages/http/cross_domain.js
View
11 source/packages/http/cross_domain.js
@@ -20,9 +20,12 @@
return JSONP_HANDLER_NAME + (HANDLER_COUNT++);
};
- var handleJsonP = function(callback, data) {
- var args = Array.from(arguments), callback = args.shift();
+ var handleJsonP = function(callback, id, data) {
+ var args = Array.from(arguments),
+ callback = args.shift(),
+ id = args.shift();
callback.apply(null, args);
+ removeHandler(id);
};
var removeHandler = function(id) {
@@ -120,8 +123,8 @@
var handlerID = getHandlerId();
uri.setParam(uri.params.jsonp, handlerID);
if (uri.params.jsonp !== 'jsonp') delete uri.params.jsonp;
- window[handlerID] = handleJsonP.partial(callbacks.onSuccess);
- callbacks.onSuccess = removeHandler(handlerID);
+ window[handlerID] = handleJsonP.partial(callbacks.onSuccess, handlerID);
+ callbacks.onSuccess = null;
}
YAHOO.util.Get[assetType](uri.toString(), callbacks);

0 comments on commit 8f9df4f

Please sign in to comment.
Something went wrong with that request. Please try again.