Jquery ajax GET请求在URL中不显示参数
我试图使用jQuery AJAX函数对表单执行GET请求,但问题是我在URL中看不到参数: 代码如下:Jquery ajax GET请求在URL中不显示参数,jquery,ajax,get,Jquery,Ajax,Get,我试图使用jQuery AJAX函数对表单执行GET请求,但问题是我在URL中看不到参数: 代码如下: <form id="search_form" method="GET" action=""> <input id="seach_input" type="text" name="q"> <button id="search_btn" class="btn btn-warning" type="submit">Search</button
<form id="search_form" method="GET" action="">
<input id="seach_input" type="text" name="q">
<button id="search_btn" class="btn btn-warning" type="submit">Search</button>
</form>
提交后,我希望URL如下所示:
http://localhost/search.html?q=value
我知道;是参数没有出现在URL中的原因,但我需要这样做,这是在不刷新页面的情况下进行的,同时,我希望在收到请求时看到参数
请帮忙
谢谢。在Chrome、Safari、FF4+和IE10等现代浏览器中,您可以使用window.history.pushState完成所需操作 这里有一篇好文章 您需要在代码中添加类似的内容
window.history.pushState(“object or string”, “Title”, “/new-url”);
此外,如果您不希望用户能够导航回来,请使用replaceState
window.history.replaceState(“object or string”, “Title”, “/another-new-url”);
您是否尝试过使用
返回false
来代替默认值?;谢谢,我会那样做的
window.history.replaceState(“object or string”, “Title”, “/another-new-url”);