$def with ()

<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 checkForMessage(){
            jQuery.ajax({
                    url:"/foobar",
                    type: "POST",
                    data: {action: "check"},
                    success: function(data) {
                        if(data){
                            jQuery("#header").html(data)
                            var element = document.getElementById("header");
        					element.scrollTop = element.scrollHeight;
                        }else{
                            jQuery("#header").html("I AM LISTENING FOR FOOBARS")
                        }
                    }
                    });
        }
		function sendMessage(){
            jQuery.ajax({
                    url:"/foobar",
                    type: "POST",
                    data: {action: "send",message :jQuery("#message").val()},
                    success: function(data) {             
    					jQuery("#message").val('')
                    }
                    });
        }
        setInterval(checkForMessage,500);
		</script>
		<div id="header"> I AM LISTENING FOR FOOBARS </div>
		<input type='text' rows='10',cols='50' id='message'></input>
		<button type="button" onclick="sendMessage()">Send Message</button>
	</body>
</html>