weixin_33743880 2014-07-28 19:41 采纳率: 0%
浏览 48

如何在PHP中重定向页面

I have an AJAX function that carry the content of a page (list.php) within a "div" the page (home.php), page (list.php) has a function that checks if the session has expired, if yes, you should go to index.php. It turns out that when I use header ('Location: index.php'); redirection is being done only within the "div" and I wish instead be redirected entire page I am (home.php). This is causing me to stay in home.php and is being shown within "div" the "index.php", and would have is showing only the "index.php"

  • 写回答

1条回答 默认 最新

  • weixin_33724570 2014-07-28 19:43
    关注

    Place the redirect in the callback of your AJAX function. You will want to use something like window.location = "" in Javascript after there is a response in your AJAX object.

    If you are using plain JS, you will want to watch for your onreadystatechange event to equal 4, then do the redirect accordingly depending on the response code and what your intended functionality is.

    评论

报告相同问题?