前进和后退按钮来控制阿贾克斯负载负载、按钮、阿贾克斯

2023-09-10 13:58:11 作者:在洱海遇见

喂在一起,

我正在寻找一个解决方案,其中的前进和后退按钮控制我的Ajax的通话记录。

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

所以,如果我做好了这部一个Ajax调用,然后preSS回我要重新加载原来的页面。

so if i maka a ajax call, and then press "back" i want to reload the original page.

如果我做一个Ajax调用,然后另一个,然后preSS后退按钮,我想再次做的第一AJAX调用。

if i do a ajax call and then another, and then press the back button i want to do the first ajax call again.

等。(也就是说,如果我现在preSS前进按钮,第二阿贾克斯科尔壳重做;-))

and so on ... (i.e. if i now would press the forward button, the second ajax coll shell be redone ;-) )

感谢

更新

嗯,我解决了一个名为 jQuery的整个事情有一个很不错的jQuery插件地址和它的作品相当不错的。

well, i resolved the whole thing with a very nice jquery plug in named jQuery Address and it works quite well.

的事情是,我有问题,让贝克在原址。我浏览到 mysite.foo/step1 然后我触发一个Ajax调用,我降落在 maysite.foo/step1#/#步骤2 ,当我现在preSS后退按钮我留在该网站上,其含量(步骤2),我不能让我的最初的登陆页面的信息,重新加载......

the thing is, that i have problems to get beck on the original site. i navigate to mysite.foo/step1 then i trigger an ajax call and i land on maysite.foo/step1#/#step2, when i now press the back button i stay on that site with its content (of step2), and i can't get information about my original landing page, to reload that ...

amendendly:我有我的地方存放它们由即第二步索引Ajax的调用数组

amendendly: i have an array where i store the ajax-calls which are indexed by i.e. step2.

step1 : {id: 1, url: /ste1.php, ... },
step2 : {id: 2, url: /step2.php, ... },...

和功能,其中还设置了哈希,调用Ajax请求。

and a function, which also sets the hash, calls the ajax request.

推荐答案

您应该保存您的AJAX状态,在该文件的位置的散列(即的http://页面的URL#AJAX状态)

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

如果您修改只是hash部件,浏览器不会做一个页面重载,但浏览器历史记录将记录URL的变化。因此,当你preSS回来,你就可以根据存储在文件哈希信息重新发挥Ajax调用。

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.

也看到这一问题: http://stackoverflow.com/questions/172957/detecting-back-button-hash-change-in-url

 
精彩推荐
图片推荐