如何在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"

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.