jQuery Mobile:登录链接转到最后一个缓存的页面 [英] JQuery mobile: login link goes to last cached page

查看:82
本文介绍了jQuery Mobile:登录链接转到最后一个缓存的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我为公司制作的Web应用程序实现移动解决方案.基于PC的主应用程序运行良好,但移动设备的行为异常.

I am trying to implement a mobile solution to a web app I am making for my company. The primary pc based app works perfectly well but the mobile piece is behaving strangely.

当前,用户注销的唯一方法是让他们访问应用程序主页并选择注销(这将最终改变,但我们仍处于早期开发阶段).当用户注销应用程序时,我将调用一个控制器(index.php),该控制器将刷新PHP会话数据,创建一个页面(form.html.php),然后用户可以单击链接以重新登录.链接将调用主控制器,该主控制器将检查是否设置了特定的会话变量,如果未设置,则重定向到登录控制器/页面.由于注销表单会刷新所有这些数据,因此应将用户重定向到登录页面.如前所述,使用PC浏览器可以正常工作.

Currently, the only way for a user to log out is for them to access the app main page and select logout (this will change eventually but we are still in early dev). When a user logs out of the app, I call a controller (index.php) that will flush the PHP session data, create a page (form.html.php) where the user can then click a link to log back in. This link will call the main controller which will check to see if specific session variables are set and if not, redirect to the login controller/page. Since the logout form flushes all of that data, the user should be redirected to the login page. As stated before, using a PC browser, this works fine.

在移动设备上发生的事情是,当用户单击链接以重新登录时,移动设备将转到注销所从的主页.由于所有会话数据均处于非活动状态,因此该页面实际上已失效.

What is happening on the mobile piece is that when the user clicks on the link to log back in, the mobile device goes to the main page where the logged out from. Since all session data is inactive, the page is effectively dead.

如何使Mobile应用程序(或JQuery mobile)停止缓存上一页?任何帮助表示赞赏.仅供参考:我只是在学习移动应用基础架构.

How can I get the Mobile app (or JQuery mobile) to stop caching the previous page? Any help is appreciated. FYI: I am just learning the mobile app infrastructure.

index.php:

index.php:

<?php
    session_start();
    $url = $_SESSION['myurl'];
    $root = $_SESSION['myroot'];
    $formTitle      = 'Exit NSI CRM';
    $formHeading    = 'NSI CRM System - Goodbye';
    $m = $_SESSION['mobile'];
    session_destroy();
    ($m?include ('m_form.html.php'):include ('form.html.php'));
    exit();
?>

m_form.html.php:

m_form.html.php:

<!DOCTYPE html> 
 <html> 
    <head> 
        <meta name="viewport" content="width=device-width, initial-scale=1"> 
        <link rel="stylesheet" type="text/css" href="<?php print 'http://'.$_SERVER['HTTP_HOST'].'/crm/css/m_crm.css';?>">
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
        <script type="text/javascript">
            google.load("jquery", "1");
        </script>
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
        <?php include $root.'/inc/favicon.php'; ?>
        <title><?php print $formTitle; ?></title>
    </head> 
    <body> 
    <div data-role="page">
        <div>
            <br>
                <img src="<?php print 'http://'.$_SERVER['HTTP_HOST'].'/crm/img/handshake.jpg';?>">
            <h3>
                You have been logged out of the NSI CRM System. Good-bye!
            <br>
                To log back in, click <a style="font-size: larger;" href="<?php echo 'http://'.$_SERVER['HTTP_HOST'].'/crm/'; ?>">here.</a>
            </h3>
        </div>
    </div><!-- /page -->
    </body>
</html>

推荐答案

您是否尝试过禁用jquery mobile的ajax功能?

Have you tried disabling the ajax functionality of jquery mobile?

$(document).bind("mobileinit", function () {
  $.mobile.ajaxEnabled = false;
});

在jquery移动框架加载之前调用此函数.

call this before the jquery mobile framework loads.

或者您可以修改回链接,并添加以下属性之一

or you could modify your link back adding one of these attributes

rel="external", data-ajax="false"

例如<a href="somepage.html" rel="external">Link</a>

参考: http://jquerymobile.com/demos /1.0a4.1/docs/pages/link-formats.html

这篇关于jQuery Mobile:登录链接转到最后一个缓存的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆