From 7c5df8ffac17fc62c85a17897d4c9ffa7f46a187 Mon Sep 17 00:00:00 2001 From: jakub Date: Wed, 21 May 2008 15:23:20 +0200 Subject: [PATCH] Refactored pz2HttpRequest --- js/pz2.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) 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 () -- 1.7.10.4