Parameterize a javascript object and create url
By Anatoly Mironov
If you want to add some parameters to an url which you want to open, you can use jQuery.param function:
var url = "some\_url";
var params = {
name: "Setner",
email: "setner@narspi.name",
mobile: "123456789"
};
var search = "?" + $.param(p);
url += search;
```It is handy, indeed. In an environment without jQuery (are there some?:) ) you can just iterate an object and join properties:
var url = “some_url”; var params = { name: “Setner”, email: “setner@narspi.name”, mobile: “123456789” }; if (url.match("/\?/g") == null) { url += “?”; } else { url += “&”; } var search = “”; for(var p in params) { search += [p, params[p]].join("="); } url += search;
##### SharePoint javascript API
There is [a nice sharepoint javascript api](http://www.wictorwilen.se/Post/Working-with-URLs-in-SharePoint-2010-JavaScripts.aspx "See Wictor Wilén's blog about working with url and SharePoint javascript API") we can use as well. Consider this example:
var u = new SP.Utilities.UrlBuilder(“http://takana.com”); u.addKeyValueQueryString(“id”, “2”); u.addKeyValueQueryString(“time”, new Date().toISOString()); u.get_url(); //“http://takana.com?id=2&time=2012%2D02%2D24T12%3A30%3A53%2E339Z"
## Comments from Wordpress.com
####
[SharePoint e Javascript – Amor ou ódio? | Rodrigo Romano - MVP SharePoint Server](http://rodrigoromano.net/2014/07/11/sharepoint-e-javascript-amor-ou-dio/ "") - <time datetime="2014-07-11 14:32:16">Jul 5, 2014</time>
\[…\] http://chuvash.eu/2012/01/24/parameterize-an-javascript-object-and-create-url/ \[…\]
<hr />