我有一个问题,能够从AJAX响应从多页布局表单提交链接回主页
结构
index.php具有多页协议(index.php#agreement)
#agreement有一个表单正在使用默认的AJAX调用提交给(agreement.php)
在agreement.php中,我可以返回到预期的最后一个页面(#agreement),但现在我想返回到index.php页面。
我可以很容易地放入href="index.php",但是会话失去了它的值。
有没有退回两步的方法?或者访问URL历史记录并指向特定页面,而不会丢失表单中的任何数据?
我在index.php中使用以下代码绑定了agreement.php
$('#agreement_status').live('pageshow',function(event, ui){
// Button action
$('#back_home').click(function(){
window.history.back(); // this goes back one page to index.php#agreement
window.history.back(-2); // this goes back one page to index.php#agreement
$.mobile.changePage("#index", "slideup"); // this works but appends the hashtag in the URL which breaks the other functionality
});
});在agreement.php中,我有以下代码
<a id="back_home"
data-role="button"
data-icon="home"
data-theme="z"
data-inline="true"
style="float:right;">
Home
</a>发布于 2011-04-02 03:01:29
好吧,这不是对我问题的真正回答,但它确实解决了我的问题:
返回按钮代码,在锚标记中使用agreement.php -rel=“back”选项,并添加一个名称/id为agreement_status的div标记
<a data-rel="back"
data-role="button"
data-icon="home"
data-theme="z"
data-inline="true"
style="float:right;">
Home
</a>在index.php页面中,将以下代码添加到您的java脚本中
$('#agreement_status').live('pagehide',function(event, ui){
window.history.back();
});当agreement_status页面被隐藏时,会触发pagehide,因此您将进入#协议页面。然后使用window.history.back();我们能够返回到index.php页面,并且仍然保留所有数据,而不需要刷新页面
发布于 2011-03-30 13:53:32
尝尝这个
window.location.href = "/index.php";https://stackoverflow.com/questions/5422492
复制相似问题