summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/gf-server-jsapi.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/server/gf-server-jsapi.js b/src/server/gf-server-jsapi.js
index 5c02395e8..26b41575a 100644
--- a/src/server/gf-server-jsapi.js
+++ b/src/server/gf-server-jsapi.js
@@ -42,10 +42,15 @@ gf.httpGetJSONP = function (url, callback) {
}
var callbackIndex = window.jsonCallbacks.length;
window.jsonCallbacks.push(function (output) {
+ // get rid of the script tag
document.getElementsByTagName("head")[0].removeChild(script);
+ // let this function be garbage-collected
+ window.jsonCallbacks[callbackIndex] = null;
+ // shrink the array if possible
+ while (window.jsonCallbacks.length > 0 && window.jsonCallbacks[window.jsonCallbacks.length-1] == null) {
+ window.jsonCallbacks.pop();
+ }
callback(output);
- window.jsonCallbacks[callbackIndex] = null; // let the function be garbage-collected
- // FIXME: there will be lots of nulls in that array, we should purge it
});
var callbackName = "jsonCallbacks[" + callbackIndex + "]";