Hello, there was a very peculiar kind of problem. On the main page of the site, the data when you click on the menu link is loaded into the block using AJAX. Everything goes as it should. But with direct access to the page that loads, it gives out only the material that needs to be loaded, it turns out that the user does not see the full site as it should look when it is uploaded, but only a part. The essence of the question is as follows. How to make it so that when the POST request was made to the page, one part was output by the Ajax, and if the page was completely displayed from the browser lines? Thanks in advance!

    2 answers 2

    The easiest option is to check HTTP_X_REQUESTED_WITH

     if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { //Пришел асинхронный запрос - выводим только обновляемую часть контента } else { //Выводим весь контент } 

    True, with some settings the server may not fill HTTP_X_REQUESTED_WITH . In this case, it remains only to use the additional parameter $_GET or $_POST and focus on it.

      If $ _GET - we give everything, if $ _POST - we give a part, it will be easier, and there will be no extra troubles with HTTP_X_REQUEST