window.location.assign无效

时间:2014-08-05 17:49:42

标签: javascript php redirect

我有以下代码:

function verifyUser(userEmail){
$.getJSON('verifyUser.php', {data : userEmail}, function(result){
    console.log(result);
alert(result.location);
console.log(window.location.href);
    window.location.href = "http://localhost/hub.php";
console.log(window.location.href);
console.log(result);
alert(result.location);
});

};

我收到的JSON返回时包含用户名,电子邮件地址:

while($row = $resultQuery->fetch_assoc()){
            $_SESSION['userName'] = $row['USERID'];
            $_SESSION['userRole'] = $row['USERROLE'];
            $returnDataLogin['success'] = true;
            $returnDataLogin['email'] = $email;
            $returnDataLogin['role'] = $row['USERROLE'];
            $returnDataLogin['location'] = 'http://localhost/hub.php';
            $returnDataLogin['message'] = 'Bienvenido '.$returnDataLogin['email'].'!';
            $json_data = json_encode($returnDataLogin, JSON_UNESCAPED_SLASHES);
            echo $json_data;
}

然后我在javascript函数上分配窗口的位置。它在WAMP服务器上完美运行,但是,一旦我将文件移动到apache服务器,它就不会重定向。什么想法可能是错的?

修改

我发现请求没有跟随,它抛出一个302(Found):

enter image description here

0 个答案:

没有答案