重定向似乎无法正常工作

时间:2012-03-15 17:08:01

标签: javascript jquery

问题是重定向不起作用,它应该在登录后忽略搜索页面,但事实并非如此。用户点击按钮预订他的书,如果他没有登录,提示框会询问他登录信息,登录后,用户应该被重定向到请求表。现在它将他带到登录表单操作中定义的搜索页面。

var cookieName = "activeRequest";
var variableName = "requestUrl";
var lifetime = 60;

$(document).ready(function() {
    "use strict";
    //$.Jookie.Initialise(cookieName,lifetime);  

    $(".public_request").click(function() {

        //alert("click");
        var url = $(this).attr("id");

        store(url);
        //alert(url);
        //return false;   
    });
});


//store the request link

function store(url) {
    "use strict";
    $.Jookie.Initialise(cookieName, lifetime);
    $.Jookie.Set(cookieName, variableName, url);


}
//check for a active request

function checkForRequest() {
    "use strict";
    $.Jookie.Initialise(cookieName, lifetime);
    var reqURL = $.Jookie.Get(cookieName, variableName);

    //check the response and see if there was one
    if (reqURL === undefined) {
        return false;
    }
    else {
        deleteCookie();
        redirect(reqURL);

    }
}

//redirect to request
function redirect(url) {
    "use strict";
    window.location = url;
}

//delete an active request after redirect
function deleteCookie() {
    "use strict";
    $.Jookie.Initialise(cookieName, lifetime);
    $.Jookie.Unset(cookieName, variableName);
}

1 个答案:

答案 0 :(得分:0)

if(reqURL === undefined)

应该是

if (typeof(reqURL) == "undefined")