Do you know a fast and simple way to encode a Javascript Object into a string
that I can pass via a GET
Request?
No jQuery
, no other frameworks - just plain Javascript :)
Do you know a fast and simple way to encode a Javascript Object into a string
that I can pass via a GET
Request?
No jQuery
, no other frameworks - just plain Javascript :)
Edit: I like this one-liner, but I bet it would be a more popular answer if it matched the accepted answer semantically:
Well, everyone seems to put his one liner here so here it goes mine:
This one skips null/undefined values
jQuery has a function for this,
jQuery.param()
, if you're already using it you can use that: http://api.jquery.com/jquery.param/example:
str
now containswidth=1680&height=1050
A little bit look better
In ES7 you can write this in one line: