JQuery: Change URL param without reloading?

谁说我不能喝 提交于 2019-12-09 11:59:52

问题


I have a question, is it possible to change the URL via JQuery under the following conditions:

  • Same URL will load on browser back and on reloads
  • Page doesn't reload when you change the parameter

回答1:


If you wanna prevent the page from reloading you'll have to use hash "#"

And if you wanna change the URL try that:

jQuery.param.querystring(window.location.href, 'valueA=321&valueB=123');

This will return the following URL:

http://bla.com/test.html?valueA=321&valueB=123




回答2:


I may be wrong but I think the browser will do a post if you change the location.

So, could it help you to use a post instead than a GET and change a hiddenfield/just set the value?

You can use jQuery.ajax() to make calls to the server setting the values you need in the post (or get, as you wish). That way the url doesn't change and you make the requests you need.



来源:https://stackoverflow.com/questions/16217326/jquery-change-url-param-without-reloading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!