124 Part I: Core Ideas
else
queryString += key + "=" + encodeValue(val) + "&";
}
}
//remove trailing &
if (!indexString && queryString != "")
queryString = queryString.substring(0,queryString.length-1);
return queryString;
}
You might wonder why you should bother to do this encoding. The simple answer is
that server-side environments will decode these values directly. To illustrate this we send
various arrays and objects to the server and print out the values, as shown in Figure 4-3.
FIGURE 4-3 Arrays and objects sent in a URL