From: jakub Date: Wed, 21 May 2008 13:23:20 +0000 (+0200) Subject: Refactored pz2HttpRequest X-Git-Tag: v1.0.9~5 X-Git-Url: http://git.indexdata.com/?p=pazpar2-moved-to-github.git;a=commitdiff_plain;h=7c5df8ffac17fc62c85a17897d4c9ffa7f46a187 Refactored pz2HttpRequest --- diff --git a/js/pz2.js b/js/pz2.js index 94d83ae..bc400b1 100644 --- a/js/pz2.js +++ b/js/pz2.js @@ -695,6 +695,7 @@ var pzHttpRequest = function ( url, errorHandler ) { pzHttpRequest.prototype = { + get: function ( params, callback ) { this._send( 'GET', params, '', callback ); @@ -714,6 +715,19 @@ pzHttpRequest.prototype = return this.request.responseXML; }, + encodeParams: function (params) + { + var sep = ""; + var encoded = ""; + for (var key in params) { + if (params[key] != null) { + encoded += sep + key + '=' + encodeURIComponent(params[key]); + sep = '&'; + } + } + return encoded; + }, + _send: function ( type, params, data, callback ) { this.callback = callback; @@ -728,17 +742,7 @@ pzHttpRequest.prototype = _urlAppendParams: function (params) { - var getUrl = this.url; - - var sep = '?'; - var el = params; - for (var key in el) { - if (el[key] != null) { - getUrl += sep + key + '=' + encodeURIComponent(el[key]); - sep = '&'; - } - } - return getUrl; + return this.url + "?" + this.encodeParams(params); }, _handleResponse: function ()