Use a javascript object instead of building a JSON string

This commit is contained in:
Nathan Gray 2010-06-09 12:39:32 +00:00
parent 0e234a718f
commit 9d4c60bc42

View File

@ -55,26 +55,18 @@ egw_json_request.prototype.sendRequest = function(_async, _callback, _sender)
if (typeof _async != "undefined") if (typeof _async != "undefined")
is_async = _async; is_async = _async;
//Assemble the actual request string //Assemble the actual request object
var request = '{'; var request_obj = new Object();
request += '"request":{'; request_obj.json_data = new Object();
if (this.parameters) request_obj.json_data.request = new Object();
if(this.parameters)
{ {
request += '"parameters":['; request_obj.json_data.request.parameters = new Array();
for (var i = 0; i < this.parameters.length; i++) for (var i = 0; i < this.parameters.length; i++)
{ {
if (i > 0) request_obj.json_data.request.parameters.push(this.parameters[i]);
{
request += ',';
} }
request += '"' + this.parameters[i] + '"';
} }
request += ']';
}
request += '}}';
var request_obj = new Object();
request_obj.json_data = request;
//Send the request via the jquery AJAX interface to the server //Send the request via the jquery AJAX interface to the server
$.ajax({url: this.url + '?menuaction=' + this.menuaction, $.ajax({url: this.url + '?menuaction=' + this.menuaction,