Skip to content

Instantly share code, notes, and snippets.

@jackofseattle
Created January 21, 2013 21:10
Show Gist options
  • Save jackofseattle/4589428 to your computer and use it in GitHub Desktop.
Save jackofseattle/4589428 to your computer and use it in GitHub Desktop.
var serialize = function(obj, prefix) {
var str = [];
for(var p in obj) {
var k = prefix ? prefix + "[" + p + "]" : p, v = obj[p];
str.push(typeof v == "object" ?
serialize(v, k) :
encodeURIComponent(k) + "=" + encodeURIComponent(v));
}
return str.join("&");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment