From 5347593d9dd103e5e07af0b54ade52cd56522d08 Mon Sep 17 00:00:00 2001 From: javi Date: Sat, 12 Jul 2014 12:49:11 +0200 Subject: [PATCH] allow custom callback --- lib/torque/request.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/torque/request.js b/lib/torque/request.js index 49e14b9..93d6b80 100644 --- a/lib/torque/request.js +++ b/lib/torque/request.js @@ -5,12 +5,13 @@ var lastCall = null; function jsonp(url, callback, options) { - options = options || { timeout: 10000 }; + options = options || {}; + options.timeout = options.timeout === undefined ? 10000: options.timeout; var head = document.getElementsByTagName('head')[0]; var script = document.createElement('script'); // function name - var fnName = 'torque_' + Date.now(); + var fnName = options.callbackName || 'torque_' + Date.now(); function clean() { head.removeChild(script);