Hi,
weiß jemand warum mein preventDefault() nicht funkioniert?
HTML:
<form id="comment-form">
<button type="submit" name="show_comments" class="show_comments" value="<?php echo $rowsafe['beichtid']; ?>">Show Comments</button>
<?php echo $count_comments; ?> <i class="far fa-comment"></i></button>
<p><input type="hidden" name="beicht-comment-id" value="<?php echo $rowsafe['beichtid']; ?>"></p>
</form>
JS:
<script>
$('#comment-form').submit(function(e) {
e.preventDefault();
$.ajax({
type: 'POST',
url: 'show_comments.php',
data: $(this).serialize(),
success: function(data) {
alert(data)
}
})
})
</script>