简体   繁体   English

如何在不更改/刷新页面的情况下基于AJAX请求更改URL?

[英]How do I change the URL based on an AJAX request without changing/refreshing the page?

I'm working on a site where users can click on certain elements that trigger an AJAX request that inject information onto the page. 我在一个网站上工作,用户可以单击某些元素来触发将AJAX请求注入到页面上的信息。 For SEO reasons, I want this to rewrite the URL but for usability reasons I don't want to refresh the page. 出于SEO的原因,我希望它重写URL,但是出于可用性的原因,我不想刷新页面。 How can I do this? 我怎样才能做到这一点?

You can use history api in html5 : pop and push state 您可以在html5 use history API: poppush state

http://html5doctor.com/history-api/ http://html5doctor.com/history-api/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM