支持自定义callback名字
parent
6f0b378c19
commit
6ce97228a7
|
@ -23,6 +23,7 @@ function jsonp(url, options) {
|
|||
options = options || {};
|
||||
var prefix = options.prefix || '__jp';
|
||||
var callback = options.callback || 'callback';
|
||||
var callbackName = options.callbackName;
|
||||
var params = options.data || {};
|
||||
var timeout = options.timeout ? options.timeout : 15000;
|
||||
var target = document.getElementsByTagName('script')[0] || document.head;
|
||||
|
@ -30,7 +31,7 @@ function jsonp(url, options) {
|
|||
var timer = void 0;
|
||||
var promise = void 0;
|
||||
// Generate a unique id for the request.
|
||||
var id = prefix + count++;
|
||||
var id = callbackName || prefix + count++;
|
||||
|
||||
function noop() {}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "simple-jsonp-promise",
|
||||
"version": "1.0.8",
|
||||
"version": "1.0.9",
|
||||
"description": "",
|
||||
"main": "build/index.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -18,6 +18,7 @@ function jsonp(url, options) {
|
|||
options = options || {};
|
||||
let prefix = options.prefix || '__jp';
|
||||
let callback = options.callback || 'callback';
|
||||
let callbackName = options.callbackName;
|
||||
let params = options.data || {};
|
||||
let timeout = options.timeout ? options.timeout : 15000;
|
||||
let target = document.getElementsByTagName('script')[0] || document.head;
|
||||
|
@ -25,7 +26,7 @@ function jsonp(url, options) {
|
|||
let timer;
|
||||
let promise;
|
||||
// Generate a unique id for the request.
|
||||
let id = prefix + (count++);
|
||||
let id = callbackName || (prefix + (count++));
|
||||
|
||||
function noop() {}
|
||||
|
||||
|
|
Loading…
Reference in New Issue