Ajax request is called php script. It ends the current session and at the end you need to refresh the page. Did in 2 ways:

  • 1st way: header ("refresh: 0");
  • 2nd way: header ("Location: ".$_SERVER['HTTP_REFERER']);

In both cases, it produces the same error in responseText. How to make it work?

  • MB to transfer a variable and from onload to refresh the page? - Sh4dow
  • What mistake? - Fucking Babai
  • ok this is understandable. I'm more interested in why php fails? Or is it not possible at all because php is called using ajax? - Kohanenko Stas
  • error: Warning: Cannot modify header information - headers already by by authOut.php on line 15 - Kokhanenko Stas
  • the fact is that the reloading of the page is obligatory! And as it is known, javascript is the easiest to fool (what thread to the clever man) - Kohanenko Stas

3 answers 3

In the callback function, specify location.reload (). After receiving the response, the page will reload.

    If you do an Ajax, then right in the script after it is executed, do

     window.location.href="/url/to/update/php" 

    This must be done in javascript.

    • You can send the path where you need to go in response from ajax and you will substitute it in JavaScript - RooTooZ

    Can one line

     header('Refresh: 0; URL='.$_SERVER['HTTP_REFERER']); 

    and the most important line should be above the closing tag </ head>

    • In this situation it is not possible. The user is waiting for the answer Ajax, and you need to reload the page. - Sh4dow