http://plugins.jquery.com/project/parseQuery
(minified it's 449 bytes http://plugins.jquery.com/files/jquery.parsequery.min_.js_.txt) On Jul 5, 1:41 pm, candlerb <b.cand...@pobox.com> wrote: > Hello, a quick question in case I'm being stupid :-) > > I see that jQuery provides a function to turn an object into a set of > URL query parameters: > > $.param({foo:"xxx", bar:"yyy"}) => "foo=xxx&bar=yyy" > > My question is: is there a function which does the opposite, i.e. > parsing a query string into an object? > > The reason is that when I make an Ajax request, I want to take some > parameters from the original page and include them in the new request, > and modify others. > > I can get the original page's query string from location.search, which > may contain, say, "?foo=xxx&bar=yyy" > > Now, suppose I want to submit an Ajax request with the same value of > foo as the original page but a different value of bar, what's the > cleanest way to do that? Remember that the original query string might > have the two parts the other way round, i.e. "?bar=yyy&foo=xxx" > > If I need to write a function to split this myself, I know it's not a > major undertaking, but I just wanted to see if I've missed something > in the API. > > Many thanks, > > Brian.