basicly you make your actions on click, but display the result later. for example your player clicks on upgraid a building. so you save in your database the new level of the building and the timestamp when the building upgraid process is done. so if player goes ingame he see the countdown if now is bigger than the timesamp so he see the new building level, else he see the building level -1.
to be clear, dont make an ajax request each second or stuff, just display content if the time is right for it.