【问题标题】:url query string change by jquery ajax function通过jquery ajax函数更改url查询字符串
【发布时间】:2012-10-04 11:23:24
【问题描述】:

我在一个页面http://www.sample.com/index.php

如何添加 URL 查询字符串。例如,当我单击按钮时,URL 变为 http://www.sample.com/index.php?value=10 而无需重新加载页面。通过使用 jquery ajax 函数。

【问题讨论】:

    标签: jquery ajax url parameters get


    【解决方案1】:

    我认为您正在寻找 History API,请查看此 history.js 库, https://github.com/browserstate/history.js

    演示: http://browserstate.github.com/history.js/demo/

    【讨论】:

      【解决方案2】:

      新的 HTML 5 浏览器支持 History API(browser supportW3C spec):

      window.history.pushState(stateObj, title, url);
      

      在 HTML 5 之前的浏览器中,您可以设置哈希标签(browser supportW3C example

      window.location.hash = "state";
      

      不支持更改哈希标签的旧浏览器无法使用此功能。

      【讨论】:

        猜你喜欢
        • 2013-06-17
        • 2011-06-21
        • 2011-04-18
        • 1970-01-01
        • 2011-11-16
        • 1970-01-01
        • 1970-01-01
        • 2017-07-11
        • 2016-10-29
        相关资源
        最近更新 更多