Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- commentForm.addEventListener('submit', function(e){
- e.preventDefault();
- if(newComment.value == ''){
- alert('please fill out a full comment');
- }else{
- var form = document.forms.namedItem("commentForm");
- var formData = new FormData(form);
- var message = newComment.value;
- var req = new XMLHttpRequest();
- req.open("POST", "comments", true);
- req.onload = function(event){
- if(req.status == 200){
- console.log("Upload!");
- createComment(message);
- }else
- console.log("error" + req.status);
- }
- req.send(formData);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement