当页面返回时,一些浏览器不保留附加的AJAX内容。

时间:2021-11-11 16:53:35

I have developed a AJAX search component to query a Google Search Appliance. It makes an AJAX call to a php script that grabs XML from the GSA and encodes it as JSON and sends it back to the browser. From there, the jquery template plugin does the rest. That process works as it should.

我开发了一个AJAX搜索组件来查询谷歌搜索设备。它对php脚本进行AJAX调用,该脚本从GSA获取XML并将其编码为JSON并将其发送回浏览器。剩下的由jquery模板插件完成。这个过程就像它应该做的那样。

However, when I navigate away from the search page (e.g., click on a result link) and later wish to return to the search results, IE and chrome do not retain the search results and your position on the page, while FF, Opera, and Safari do retain the the AJAX content appended to the DOM and your position on the pae. In IE and Chrome, it is essentially hitting back and seeing a blank page w/ no results.

然而,当我远离导航搜索页面(例如,单击一个链接),后来想返回搜索结果,IE和chrome不保留页面上的搜索结果和你的位置,尽管FF,Opera和Safari做保留AJAX内容附加到DOM和pae。在IE和Chrome浏览器中,它基本上是在回键,看到一个空白页没有结果。

Is there a reason why the browsers behave differently? (some browsers show appended content when you go back to the page, some don't)

浏览器的行为有什么不同的原因吗?(当你回到页面时,有些浏览器会显示附加的内容,有些则不会)

Is there a way to easy way to fix this without some type of session or state or storage?

有没有一种简单的方法可以在没有会话、状态或存储的情况下修复它?

Thanks

谢谢

1 个解决方案

#1


1  

How i would do it is basically when you hit search your change the location of the page without actually redirecting ( ex: http://myurl.com/search.html#mysearchtext(url encoded))

我的做法是,当你点击搜索时,你会改变页面的位置,而无需重新定向(例如:http://myurl.com/search.html#mysearchtext(url编码))

Then you do your search.

然后进行搜索。

On the onload event of your page you check for any #xxxxx in the url, and if one exists make the search.

在页面的onload事件中,您将检查url中的任何#xxxxx,如果存在,请进行搜索。

It serves 2 purpose : - This way your back action will work always :P - This way you can link your search results directly.

它有两个目的:-这样你的背动作将永远有效:P -这样你可以直接链接你的搜索结果。

#1


1  

How i would do it is basically when you hit search your change the location of the page without actually redirecting ( ex: http://myurl.com/search.html#mysearchtext(url encoded))

我的做法是,当你点击搜索时,你会改变页面的位置,而无需重新定向(例如:http://myurl.com/search.html#mysearchtext(url编码))

Then you do your search.

然后进行搜索。

On the onload event of your page you check for any #xxxxx in the url, and if one exists make the search.

在页面的onload事件中,您将检查url中的任何#xxxxx,如果存在,请进行搜索。

It serves 2 purpose : - This way your back action will work always :P - This way you can link your search results directly.

它有两个目的:-这样你的背动作将永远有效:P -这样你可以直接链接你的搜索结果。