Skip to content

Instantly share code, notes, and snippets.

@cafedomingo
Created August 23, 2010 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cafedomingo/545091 to your computer and use it in GitHub Desktop.
Save cafedomingo/545091 to your computer and use it in GitHub Desktop.
serializeToQueryString(obj, props)
{
var params = [];
for(prop in obj)
{
if(obj.hasOwnProperty(prop)
&& (!(props instanceOf Array) || props.indexOf(prop) >= 0)
{
params.push(prop + "=" encodeURIComponent(obj[prop]));
}
}
return "?" + params.join("&");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment