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.
我该怎么做?
最佳答案
这是一个老问题,但它在谷歌搜索结果中排在第一位。
我采用的解决方案与 jAndy 的类似。
window.location.pathname
给我没有查询字符串的页面 url。
然后,我可以使用 "?"+$.param({'foo':'bar','base':'ball'})
构建查询字符串,然后将其附加到路径名并设置为 window.location.href
。
window.location.href = window.location.pathname+"?"+$.param({'foo':'bar','base':'ball'})
关于javascript - jQuery/Javascript - 使用附加的查询字符串重新加载当前页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3281020/