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:

1-й способ: header ("refresh: 0"); 2-й способ: header ("Location: ".$_SERVER['HTTP_REFERER']); 

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

ERROR SUCH:

Warning: Cannot modify header information - headers already sent by (output started at Z:\home\koxan.ru\www\PHP\authOut.php:11) in Z:\home\koxan.ru\www\PHP\authOut.php on line 15

  • 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
  • one
    And you translate a mistake, we can become clearer) Everything is simple. From pkhp it does not work, because you load the text page, and instead of the text comes the redirection header ( there is no text). - Sh4dow

1 answer 1

We have already explained that after requesting an Ajax, when receiving a response, it is necessary to do a refresh right in javascript! After sending data and receiving an answer, put the line

 location.reload(true); 

Example

 $.post('куда посылаем',{имя:параметр},function(dates){ location.reload(true); }); 

Everything. After returning the answer, the script will simply go to the reload.