I have several forms in my html view (they displayed by php foreach). Form example:
<form method="POST" class="like-form-js">
<input type="hidden" name="post_id" value="<?= $post['id'] ?>">
<input type="hidden" name="user_id" value=<?= CoreController::findIndentityId(); ?>">
<i class="far fa-thumbs-up color-grey c-pointer submit-like"></i>
</form>
I have many such forms in my view. My js:
$('.submit-like').click( function() {
$.ajax({
url: 'some-url',
type: 'post',
dataType: 'json',
data: $('.like-form-js').serialize(),
success: function(data) {
console.log('success');
}
});
});
I need to submit only one form on which i clicked, but this forms have similar class and they are all submiting. How to solve this?