Created
December 15, 2014 23:56
-
-
Save jsatk/29ef7c004179e3149038 to your computer and use it in GitHub Desktop.
URI Encode JS Object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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