From 62538ede2e537a17383b573f0b4c93e1474e8f61 Mon Sep 17 00:00:00 2001 From: Dario Villanueva Date: Mon, 26 Nov 2012 16:25:01 +0000 Subject: [PATCH 1/2] added support for POST requests --- src/importers/remote.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/importers/remote.js b/src/importers/remote.js index b1be5c2..13382cc 100644 --- a/src/importers/remote.js +++ b/src/importers/remote.js @@ -11,6 +11,8 @@ * extract - a method to pass raw data through before handing back to parser. * dataType - ajax datatype * jsonp - true if it's a jsonp request, false otherwise. + * type - wether to do a post or a get request (defaults to 'GET') + * postData - The post data to send with the request */ Dataset.Importers.Remote = function(options) { options = options || {}; @@ -20,11 +22,18 @@ // Default ajax request parameters this.params = { - type : "GET", + type : "GET", // if you define type, otherwise "get" url : _.isFunction(this._url) ? _.bind(this._url, this) : this._url, dataType : options.dataType ? options.dataType : (options.jsonp ? "jsonp" : "json"), callback : options.callback }; + + // support for POST requests, just define them here. + if (options.hasOwnProperty('postData') && options.hasOwnProperty('type')) { + this.params.type = options.type; + this.params.data = options.postData; + } + }; _.extend(Dataset.Importers.Remote.prototype, Dataset.Importers.prototype, { From ea9282ae151e4b9d1aa84024e21f9ece7c8df776 Mon Sep 17 00:00:00 2001 From: Dario Villanueva Date: Thu, 10 Jan 2013 21:30:33 +0000 Subject: [PATCH 2/2] changing postData to data to follow jquery convention --- src/importers/remote.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/importers/remote.js b/src/importers/remote.js index 13382cc..06eb044 100644 --- a/src/importers/remote.js +++ b/src/importers/remote.js @@ -12,7 +12,7 @@ * dataType - ajax datatype * jsonp - true if it's a jsonp request, false otherwise. * type - wether to do a post or a get request (defaults to 'GET') - * postData - The post data to send with the request + * data - The post data to send with the request */ Dataset.Importers.Remote = function(options) { options = options || {}; @@ -29,9 +29,9 @@ }; // support for POST requests, just define them here. - if (options.hasOwnProperty('postData') && options.hasOwnProperty('type')) { + if (options.hasOwnProperty('data') && options.hasOwnProperty('type')) { this.params.type = options.type; - this.params.data = options.postData; + this.params.data = options.data; } };