I have this function. I don't understand why the form is submitted twice. Infact the request I see at the server hapijs is double.
$(function(){
$('form').on('submit', function(event){
event.preventDefault();
var $form = $(this);
$.post('/send-message', {
data: $form.serialize()
}, function(data) {
})
.fail(function(data){
});
});
});
EDIT:
I have realized that placing the script at the top is executed just once. Why?