
Some LSAPI methods support passing parameters using the HTTP GET method. It is important that the parameters are encoded according to the URI specification RFC-2396. To do so, use the JavaScript encodeURIComponent function. Note that both the parameter name and value must be encoded.
The following example shows how to define parameters for GET requests:
// paramsMap is an array of objects, each object has 2 properties: name and value.
// For example: [{name:"name1", value:"value1"}, ..., {name:"nameN", value:"valueN"}]
function prepareGETParameters(paramsMap) {
var result = "";
for (var i=0; i<paramsMap.length; i++) {
var paramName = paramsMap[i].name;
var paramValue = paramsMap[i].value;
var paramNameEncoded = encodeURIComponent(paramName);
var paramValueEncoded = encodeURIComponent(paramValue);
result += paramNameEncoded + "=" + paramValueEncoded;
if (i != paramsMap.length -1) {
result += "&";
}
}
return result;
}