I have a text area that's meant to mimic the effects of a chat box I.E. when I press enter it makes an AJAX request. The problem is that the request is made twice:
$('html').on('keyup', '#message-text', function(e){
if(e.which == 13 && !e.shiftKey){
e.preventDefault();
e.stopPropagation();
$.ajax({...},
success: function(){
console.log("*****POST****");
},
error: function(){
console.log("failure");
}
})
}
});
Whenever I press enter, the AJAX request is made successfully twice and in the console ****POST****
is logged twice when the button is pressed once. The source for one log is from messages.js:43
(my file) and a file I'm not familiar with VM3339:43
. What's the issue?