jQuery.param does exactly that. If you don't use jquery, take at look at the source.
If you're really keen to reinvent wheels though, it goes like this:
url = Object.keys(data).map(function(k) { return encodeURIComponent(k) + '=' + encodeURIComponent(data[k]) }).join('&')Read full article from javascript - Is there any native function to convert json to url parameters? - Stack Overflow
No comments:
Post a Comment