Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery/Javascript - reload current page with an appended querystring?

I've got a dropdown menu on my form, which when something is selected I need to reload the current page, but with an appended querystring.

How would I go about doing this?

like image 363
Probocop Avatar asked Jul 19 '10 12:07

Probocop


1 Answers

This is an old question but it came up first in google search results.

The solution I went with is similar to jAndy's.

window.location.pathname gives me the page's url without the query string. I'm then able to build the query string with "?"+$.param({'foo':'bar','base':'ball'}) which I then append to the pathname and set to window.location.href.

window.location.href = window.location.pathname+"?"+$.param({'foo':'bar','base':'ball'}) 
like image 167
jgreen Avatar answered Sep 22 '22 10:09

jgreen