jQuery has a param() function, I’m looking for similar functionality. I need to return a url in my object. For example:
url: function() {
return this.baseUrl + '?' + $.param({page: this.page, perPage: this.perPage});
},
this will return a url in the form of example.com/?page=1&perPage=5 or something similar. How can I form the url example.com/page/1/perpage/5?
You can create your own function:
The only problem is that the order of the parameters is not guaranteed (which is not a problem for query strings but might be for this kind of URLs). You might also want to add a check if
basealready ends with a slash or not.