$(document).delegate无效

时间:2014-11-21 12:36:44

标签: php jquery ajax html5

我已登录到我的网站,现在我希望如果用户已登录,则他/她将不会重定向到索引页

这是jquery

$(document).delegate("#index", "pagebeforeshow", function() {
    $.post('functions/session_check.php', {
        }, function(data) {
            var status = $.trim(data);
            if(status=="logged in"){
                window.location.href='welcome.html';
            }
        })
}); 

这是我的php

<?php

include '../include/config.php';
$email = $_SESSION['email'];
if (isset($email)) {
    print_r('logged in');
}
?>

这里是html

<div data-role="page" class="jqm-demos jqm-home" id="index">
            <div data-role="header" class="jqm-header">
                <h1><img src="_assets/img/jquery-logo.png" alt="jQuery Mobile"></h1>
            </div>
            <div role="main" class="ui-content">

但问题是:它不会进入此代码。

}, function(data) {
                var status = $.trim(data);
                if(status=="logged in"){
                    window.location.href='welcome.html';
                }
            })

0 个答案:

没有答案
相关问题