I came across old web application which has the code to read the parameters from the URL of the site. The code is full of string processing.
http://hostname.domain[port number]/application name?arg1=value1...&argN=valueN
Considering that URL parameters are always encoded it is litter difficult to rely on string processing. Also not sure if one can rely 100% on the URLEncode/Decode functions of the JavaScript.
function getURLParameters(){
if (location.search != "")
{
var x = location.search.substr(1).split(";")
for (var i=0; i<x.length; i++)
{
var y = x[i].split("=");
alert("Key '" + y[0] + "' has the content '" + y[1]+"'")
}
}
}
Now that made me think if there is any better way we can read values from URL ? OR should we go ahead and change the approach itself by sending values using POST/dumping JSON object on cliente ? Please help me with this.