Skip to content

Instantly share code, notes, and snippets.

@jsatk
Created December 15, 2014 23:56
Show Gist options
  • Select an option

  • Save jsatk/29ef7c004179e3149038 to your computer and use it in GitHub Desktop.

Select an option

Save jsatk/29ef7c004179e3149038 to your computer and use it in GitHub Desktop.
URI Encode JS Object
var serialize = function (obj) {
var str = [];
for (var prop in obj) {
if (obj.hasOwnProperty(prop)) {
str.push(encodeURIComponent(prop) + "=" + encodeURIComponent(obj[prop]));
}
}
return str.join("&");
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment