Skip to content
Browse files

Some small optimizations in $.ajaxJSONP. Make sure not to overwrite @…

…johannburkard’s changes from commit 09cdbc4.
  • Loading branch information...
1 parent a7bfe48 commit 3611f6cf1da77691042df45121a1a05096a48dd0 @mathiasbynens mathiasbynens committed Feb 21, 2011
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/ajax.js
View
7 src/ajax.js
@@ -6,8 +6,11 @@
$.ajaxJSONP = function(options){
var jsonpString = 'jsonp' + ++jsonpID,
script = document.createElement('script');
- window[jsonpString] = options.success;
- script.src = options.url.replace(/callback=\?/, 'callback=' + jsonpString);
+ window[jsonpString] = function(data){
+ options.success(data);
+ delete window.jsonpString;
+ };
+ script.src = options.url.replace(/=\?/, '=' + jsonpString);
$('head').append(script);
};

0 comments on commit 3611f6c

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