0

我有一个 HTML 页面,在加载时会触发一些 AJAX 调用,这些调用的结果要么存储在隐藏的文本区域(主要用于 JSON 输出)中,要么存储在 div 中(用于返回 HTML 内容的 ajax 调用)。

我想要做的是避免在离开页面然后使用后退按钮时进行那些 AJAX 调用。这实际上适用于存储在文本区域中的 AJAX 输出,实际上在返回数据之后仍然存储在这些字段中而无需重新调用那些 AJAX 请求,但对于直接在 DIV 中输出的内容,情况并非如此,这意味着必须重新调用请求。

你能给我什么建议来管理这个?谢谢

4

1 回答 1

1

This actually works for the AJAX output stored in text-area, where in fact after a back data is still stored in those fields without having to re-call those AJAX requests, but for what is directly outputted in a DIV it is not the case, meaning that the request will have to be re-called.

Browsers "cache" content of form fields under certain conditions; but they won't "cache" dynamically added HTML elements.

What advice can you give me for managing this?

With an appropriate caching policy making the AJAX request a second time should not be too costly - the browser will figure that he already has this resource in his cache, and it should be available almost immediately, without any delays caused by an extra HTTP request.

于 2013-06-24T10:42:20.493 回答