oaubcw
Last Updated: February 25, 2016
·
2.41K
· ChrisMissal

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'

See: http://api.jquery.com/jQuery.param/

3 Responses
Add your response

3055

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 ·
3056

@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 ·
3057

@ChrisMissal Fair enough! :)

over 1 year ago ·