oaubcw
Last Updated: February 25, 2016
·
2.353K
· ChrisMissal
3c4478e6ae6c60b73d21c9fa0d1785ea

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/

Say Thanks
Respond

3 Responses
Add your response

3055
6028b1c54dac0d98767d9efcb3d643b9

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
3c4478e6ae6c60b73d21c9fa0d1785ea

@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
6028b1c54dac0d98767d9efcb3d643b9

@ChrisMissal Fair enough! :)

over 1 year ago ·