Animal
10-10-2006, 08:47 AM
I've just had some extra stuff put in a URL because I've added a function to Object's prototype.
Perhaps
for(key in params){
buf.push(encodeURIComponent(key), '=', encodeURIComponent(params[key]), '&');
}
should be
for(key in params){
if (params.hasOwnProperty(key)){
buf.push(encodeURIComponent(key), '=', encodeURIComponent(params[key]), '&');
}
}
Although, I can see people passing real, functional Objects to have their properties passed back to the server, so possibly:
for(key in params){
if (params.hasOwnProperty(key)){
var v = params[key];
if (typeof v == 'function')
{
if (key.startsWith("get"))
key = key.substr(3);
else if (key.startsWith("is"))
key = key.substr(2);
v = v.call(params);
}
if (typeof v == 'string')
buf.push(encodeURIComponent(key), '=', encodeURIComponent(v), '&');
}
}
where
String.prototype.startsWith = function(prefix)
{
return this.substr(0, prefix.length) == prefix;
}
BTW, just noticed the resizable textbox! Nice one!
Perhaps
for(key in params){
buf.push(encodeURIComponent(key), '=', encodeURIComponent(params[key]), '&');
}
should be
for(key in params){
if (params.hasOwnProperty(key)){
buf.push(encodeURIComponent(key), '=', encodeURIComponent(params[key]), '&');
}
}
Although, I can see people passing real, functional Objects to have their properties passed back to the server, so possibly:
for(key in params){
if (params.hasOwnProperty(key)){
var v = params[key];
if (typeof v == 'function')
{
if (key.startsWith("get"))
key = key.substr(3);
else if (key.startsWith("is"))
key = key.substr(2);
v = v.call(params);
}
if (typeof v == 'string')
buf.push(encodeURIComponent(key), '=', encodeURIComponent(v), '&');
}
}
where
String.prototype.startsWith = function(prefix)
{
return this.substr(0, prefix.length) == prefix;
}
BTW, just noticed the resizable textbox! Nice one!