From a8374c634024165d6eff92411fc1ccc886168d5f Mon Sep 17 00:00:00 2001 From: BenjaminVadant Date: Fri, 29 Jan 2016 18:10:06 +0100 Subject: [PATCH] Adding post request support --- README.md | 13 +++ dist/leaflet.ajax.js | 171 ++++++++++++++++++++------------------- dist/leaflet.ajax.min.js | 2 +- src/ajax.js | 11 ++- src/index.js | 6 +- 5 files changed, 117 insertions(+), 86 deletions(-) diff --git a/README.md b/README.md index e3c0b2d..be3383f 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,19 @@ var geojsonLayer = L.geoJson.ajax("route/to/esri.json",{ }); ``` +You can also use a post request by supplying post parameters : + +```javascript +var geojsonLayer = L.geoJson.ajax("route/to/esri.json",{ + post : {postField : 'data1'} + }); + + //or + +geojsonLayer.refresh("route/to/esri.json", postData); +``` + + addUrl does not clear the current layers but adds to the current one, e.g.: ```javascript diff --git a/dist/leaflet.ajax.js b/dist/leaflet.ajax.js index 66db9cc..d3f405d 100644 --- a/dist/leaflet.ajax.js +++ b/dist/leaflet.ajax.js @@ -1,4 +1,77 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o element; its readystatechange event will be fired asynchronously once it is inserted + // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called. + var scriptEl = global.document.createElement('script'); + scriptEl.onreadystatechange = function () { + nextTick(); + + scriptEl.onreadystatechange = null; + scriptEl.parentNode.removeChild(scriptEl); + scriptEl = null; + }; + global.document.documentElement.appendChild(scriptEl); + }; + } else { + scheduleDrain = function () { + setTimeout(nextTick, 0); + }; + } +} + +var draining; +var queue = []; +//named nextTick for less confusing stack traces +function nextTick() { + draining = true; + var i, oldQueue; + var len = queue.length; + while (len) { + oldQueue = queue; + queue = []; + i = -1; + while (++i < len) { + oldQueue[i](); + } + len = queue.length; + } + draining = false; +} + +module.exports = immediate; +function immediate(task) { + if (queue.push(task) === 1 && !draining) { + scheduleDrain(); + } +} + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],2:[function(require,module,exports){ 'use strict'; var immediate = require('immediate'); @@ -253,80 +326,7 @@ function race(iterable) { } } -},{"immediate":2}],2:[function(require,module,exports){ -(function (global){ -'use strict'; -var Mutation = global.MutationObserver || global.WebKitMutationObserver; - -var scheduleDrain; - -{ - if (Mutation) { - var called = 0; - var observer = new Mutation(nextTick); - var element = global.document.createTextNode(''); - observer.observe(element, { - characterData: true - }); - scheduleDrain = function () { - element.data = (called = ++called % 2); - }; - } else if (!global.setImmediate && typeof global.MessageChannel !== 'undefined') { - var channel = new global.MessageChannel(); - channel.port1.onmessage = nextTick; - scheduleDrain = function () { - channel.port2.postMessage(0); - }; - } else if ('document' in global && 'onreadystatechange' in global.document.createElement('script')) { - scheduleDrain = function () { - - // Create a