$def with (mainHeader)

<html>
	<head>
		<title>$mainHeader</title>
		<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
		<style>
			#header{
				height:300px;
				overflow:scroll;
			}

		</style>
	</head>

	<body>
		<script>
		function updateHeader(){
            jQuery.ajax({
                    url:"/chat",
                    type: "POST",
                    data: {action: "update"},
                    success: function(data) {
                        jQuery("#header").html(data)
                        var element = document.getElementById("header");
    					element.scrollTop = element.scrollHeight;
                        }
                    });
        }
		function sendMessage(){
            jQuery.ajax({
                    url:"/chat",
                    type: "POST",
                    data: {action: "submit",message :jQuery("#message").val()},
                    success: function(data) {
                        jQuery("#header").html(data)
                        var element = document.getElementById("header");
    					element.scrollTop = element.scrollHeight;
    					jQuery("#message").val('')
                        }
                    });
        }
        setInterval(updateHeader,500);
		</script>
		<div id="header"> IF YOU'RE SEEING THIS MESSAGE THE SERVER FAILED </div>
		<input type='text' rows='10',cols='50' id='message'></input>
		<button type="button" onclick="sendMessage()">Send Chat</button>
	</body>
</html>