back and forward buttons to control ajax loads

后端 未结 1 1170
醉梦人生
醉梦人生 2021-01-06 15:43

hallo together,

i am searching for a solution, where the back and forward buttons control my ajax-call history.

so if i maka a ajax call, and then press \"ba

1条回答
  •  北海茫月
    2021-01-06 16:20

    You should save your ajax "state" in the document location hash (i.e. http://page-url#ajax-state ).

    If you modify just the hash component, the browser won't do a page reload, but the browser history will record a change of URL. Therefore, when you press back, you'll be able to re-play the ajax call based on the information stored in the document hash.

    See also this question: Detecting Back Button/Hash Change in URL

    0 讨论(0)
提交回复
热议问题