When the form posts, it needs to reload the page.
one way to accomplish this would be to have the server behavior that processes the form information redirect back to the same page and include a query string variable, for example:
pageName.php?status=thankYou
you could then dynamically set the visibility of the div using PHP code:
<div id="apDiv1" style="visibility: <?php echo isset($_GET['status'])?"visible":"hidden" ?>;">Thank you message</div>