My advice: read about the server part of the code, the client. At the time when the page is generated, the server code (PCP) is already running. Those. the LoadMarket () function will work before clicking on the link. Hence, the need to implement the algorithm given in the question disappears. Summarizing: everything we write in the server code, in this case, in php work even BEFORE user interaction. That is, using php we create a page as if we wrote it "manually", without using a server. We create markup on it, with some kind of functionality and interaction between elements at the client level. That is, if we in php want to create a link, upon clicking on which we would fall out a window with a message variable, for example equal to Hello World , then we would use the following code:
$someVar = 'Hello World'; echo "<a href='javascript:alert(\"$someVar\")'>Click me</a>"`.
Due to the lack of meaning in this, as such, the client should deal with these tasks: <li><a href="#" onclick="$('div.page_content').toggle()">Магазин</a></li>
Or, we form a page starting from the initial parameters (in this case in the request)
//php $mode = $_GET('mode'); //Получаем параметр mode из ссылки if($mode == 'market'){//проверяем его значение <? <div id="content_page" class="page_content"> <? include'includes/market.php'; ?> </div> ?> }else{ <? <div id="content_page" class="page_content"> <? include'includes/ar_home.php'; ?> </div> ?>
And we get access to the store from the link type .../index.php?mode=market