Add tests and documentation for ol.net.jsonp
ol.net.Jsonp was renamed to ol.net.jsonp, because it is not a constructor.
This commit is contained in:
@@ -1,17 +1,21 @@
|
||||
goog.provide('ol.net.Jsonp');
|
||||
goog.provide('ol.net');
|
||||
|
||||
|
||||
/**
|
||||
* Simple JSONP helper. Supports error callbacks and a custom callback param.
|
||||
* The error callback will be called when no JSONP is executed after 10 seconds.
|
||||
*
|
||||
* @param {string} url Request url. A 'callback' query parameter will be
|
||||
* appended.
|
||||
* @param {Function} callback Callback on success.
|
||||
* @param {function()=} opt_errback Callback on error.
|
||||
* @param {string=} opt_callbackParam Callback parameter. Default is 'callback'.
|
||||
* @param {string=} opt_callbackParam Custom qurey parameter for the JSONP
|
||||
* callback. Default is 'callback'.
|
||||
*/
|
||||
ol.net.Jsonp = function(url, callback, opt_errback, opt_callbackParam) {
|
||||
ol.net.jsonp = function(url, callback, opt_errback, opt_callbackParam) {
|
||||
var script = goog.global.document.createElement('script');
|
||||
script.async = true;
|
||||
var key = 'ol_callback_' + goog.getUid(callback);
|
||||
var key = 'olc_' + goog.getUid(callback);
|
||||
script.src = url + (url.indexOf('?') == -1 ? '?' : '&') +
|
||||
(opt_callbackParam || 'callback') + '=' + key;
|
||||
var timer = goog.global.setTimeout(function() {
|
||||
|
||||
Reference in New Issue
Block a user