allow custom callback

This commit is contained in:
javi 2014-07-12 12:49:11 +02:00
parent 7a75d44eb6
commit 5347593d9d

View File

@ -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);