像这样修改函数:
function sendForm(e){ e.preventDefault();}
正如评论所提到的,通过事件:
onclick = sendForm(event);
更新2:
$('#form-button-submit').on('click', function(e){ e.preventDefault(); var name = $('input#name').val(), email = $('input#email').val(), comments = $('textarea#comments').val(), formData = 'name=' + name + '&email=' + email + '&comments=' + comments; $.ajax({ type: 'post', url: 'js/sendEmail.php', data: formData, success: function(results) { $('ul#response').html(results); } });});
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)