You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							26 lines
						
					
					
						
							1012 B
						
					
					
				
			
		
		
	
	
							26 lines
						
					
					
						
							1012 B
						
					
					
				<script>
 | 
						|
                window.onload = function () {
 | 
						|
                        refreshComments();
 | 
						|
                };
 | 
						|
 | 
						|
                function refreshComments() {
 | 
						|
                        var xhr = new XMLHttpRequest();
 | 
						|
                        xhr.open("GET", "./comments");
 | 
						|
                        xhr.onload = function () {
 | 
						|
                                document.querySelector("#comments").innerHTML = xhr.responseText;
 | 
						|
                        };
 | 
						|
                        xhr.send();
 | 
						|
                }
 | 
						|
 | 
						|
                window.submitComment = function (evt) {
 | 
						|
                        evt.preventDefault();
 | 
						|
                        var xhr = new XMLHttpRequest();
 | 
						|
                        xhr.open('POST', './comments', true);
 | 
						|
                        xhr.send(JSON.stringify({"text": evt.target.querySelector('textarea').value}));
 | 
						|
                        xhr.onload = function () {
 | 
						|
                                refreshComments();
 | 
						|
                        }
 | 
						|
                }
 | 
						|
</script>
 | 
						|
<div id="comments"></div>
 | 
						|
 | 
						|
 |