2013-02-15 74 views
0

我有下面的代碼工作,但dosent達到預期效果:jQuery的Cookie的插件和重定向

$(".switch_org").click(function(e){ 

    var id = $(this).attr('id');   
    var orgID = id.split("_"); 

    e.preventDefault(); 

    $.cookie('current_organisation', orgID[1], { expires: 1, path: '/' }); 
    window.location.replace("index.php"); 

}); 

cookie設置工作正常但網頁是不是重定向到index.php它只是重新加載相同的頁面。難道我做錯了什麼?是否有額外的步驟可以添加,以便它重定向到index.php?

感謝

回答

0

不要使用window.location.replace,直接值分配給

window.location

windows.location.href 
+0

我曾嘗試這些,我又嘗試過,仍然只是用新的cookie集重新加載相同的頁面。 – Elliot 2013-02-15 09:13:53