jQuery - Turn JavaScript Object into query string
The method to turn an object directly into a query string with jQuery is the param method:
var obj = { name: 'chris', id: 21 };
var queryString = $.param(obj);
// results in : 'name=chris&id=21'
Written by Chris Missal
Related protips
3 Responses
Not trying to be rude, but how is this a "pro tip"? All you did was pull a method from the jQuery docs and then linked to it?
over 1 year ago
·
@bluetidepro I suppose "pro tip" isn't always black and white. This just came out of a conversation and the answer wasn't easily found at first. When I realized how easy it was to do, I created the tip as mostly a reminder to myself. I figured others that didn't know about $.param might find it useful as well.
over 1 year ago
·
@ChrisMissal Fair enough! :)
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Jquery
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#