是否有可能持续下去(无需重新加载)跨BACK按钮点击AJAX页面状态?有可能、按钮、加载、状态

2023-09-11 01:11:40 作者:吃藕

我熟悉的几种方法,以使在各种情况下的AJAX应用程序的后退按钮的工作,但我还没有发现,将工作正常在我的特定情况下的解决方案。

我有工作的网页是一个网站的搜索界面。您进入一个正常的搜索框项,点击去风在搜索结果页面,在搜索结果页面有一吨UI控件过滤/排序搜索结果中找到你所寻找的。有些通过这些控制引发的操作可能需要(相对)长的时间来完成(例如,几秒钟)。

这延迟罚款情况下,用户最初筛选/排序的结果...有一个很好的AJAX微调等等......然而,当用户点击一个搜索结果,然后点击返回按钮,我想在页面立即恢复到状态,它是当他们点击过研究。

我可以使用的IFRAME /片段标识符页历史的字典恢复状态,但是最终情况是,当用户第一次点击后退按钮的初始页面加载,那么它(重新)使AJAX查询获得页面状态恢复,从而引发了AJAX微调,并可能几秒钟另一个等待。

有没有不需要这种类型的页面的两阶段负荷时通过BACK按钮用户返回的页面?

任何方法

编辑补充:我偏jQuery的,但我很高兴与依赖于其他库/工具包,或者是独立的/原始的JavaScript解决方案

编辑补充:我应该补充说,我试图避免的Cookie /会话,因为这prevents人有多个布劳尔窗口/选项卡中打开和处理不同组搜索结果的同时

编辑:马特,您能详细的建议的解决方案(通过触发片段标识符页面更改事件)吗?我怎么看这将有助于BACK按钮点击在相同的页面,但点击一个特定的结果后,没有回来的搜索结果页面。

解决方案

尝试使用的localStorage 对象。这里是crossbrower库 jStorage 和的 WEBSHIMS JSON存储

I am familiar with several approaches to making the back button work in AJAX applications in various situations, but I have not found a solution that will work gracefully in my specific scenario.

我电脑看不了视频,优酷 土豆 爱奇艺

The pages I am working with are the search interface for a site. You enter terms in a normal search box, click "go and wind up at a search results page. On the search results page there are a ton of UI controls for filtering/sorting the search results to find what you are looking for. Some of the operations triggered by these controls may take a (relatively) long time to complete (e.g. several seconds).

This latency is fine in case where the user is initially filtering/sorting their results... there's a nice AJAX spinner and so on... however when the user clicks on a search result and then clicks on the BACK button, I would like the page to instantly be restored to the state it was in when they clicked through.

I can restore the states using IFRAMEs/fragment identifiers as a dictionary of page history, but what ends up happening is that when the user first hits the back button the initial page is loaded, then it (re) makes the AJAX query to get the page state back, which triggers the AJAX spinner and another wait of possible several seconds.

Is there any approach that does not require this kind of two-stage load of the page when the user returns to the page via the BACK button?

Edited to add: I am partial to jquery but I'd be happy with solutions that depend on other libraries/toolkits or that are standalone/raw javascript.

Edited to add: I should've added that I'm trying to avoid cookies/sessions because this prevents people having multiple brower windows/tabs open and manipulating different sets of search results at the same time.

Edit: Matt, can you elaborate on your proposed solution (triggering a page change event via fragment identifer)? I see how this would help with BACK button clicks across the same page but not coming BACK to the search results page after clicking on a specific result.

解决方案

Try to use localStorage object. Here is crossbrower libs jStorage and WEBSHIMS json-storage