There is a piece of code with ajax loading information and calling the function immediately after that. How to make so that in the case of the very first request the welcome page was called, and after clicking on the button the function with content was loaded. I do this, but for some reason every time the first if block is loaded and even when the page is updated, the count counter does not grow, but is reset.
$(function() { var pathToSome = 'some.php'; var count = 0; $.get(pathToSome, function(data) { if (count === 0) { $('#content').html("<h1>Стартовая страница</h1><p><a href="#">Перейти</a></p>"); } else { someFunction(); console.log("Do some function"); } count++; }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="panel-body" id="content"></div>
countfor$(function() {. - Suvitruf ♦countis still reset - Vasya