I'm developing an app in Spring Boot with JSP in frontend. I have the following problem:
I have a table with different rows. I can click a button to update every row if I want. When I click in one row and change some data all works fine. The problem is when I click in one row, close or save this modal and following I open another row and edit again. The modal is good but when I save, I receive 2 POST to update the row behind and the actually row.
I don't use nothing strange... Probably I need to "clean" the modal when I close or save?
One of my modals (this happends in all table with modal to update the row)
Html/JSP:
<!-- UPDATE DISP MODAL -->
<div id="updateDispModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <form id="updateDispForm" class="needs-validation">
                <div class="modal-header">
                    <div class="modal-title">
                        <h5 id="modalTitle">
                            <spring:message code="shares.displacement.update.btn" />
                        </h5>
                    </div>
                </div>
                <div class="modal-body">        
                    <div class="row">
                        <div class="col-sm-12 col-md-6">
                            <div class="form-group">
                                <label for="activityCenter" class="col-form-label"><spring:message code="shares.displacement.table.activity.center" /></label>
                                <select id="activityCenter" name="activityCenter" class="form-control" required>
                                    <option disabled selected="selected">
                                        <spring:message code="shares.displacement.table.activity.center" />
                                    </option>
                                    <c:forEach items="${teamLeaders}" var="teamLeader">
                                        <option value="${teamLeader.userId}">
                                            <spring:message code="${teamLeader.name} ${teamLeader.surnames}" />
                                        </option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="col-sm-12 col-md-6">
                            <div class="form-group">
                                <label for="displacementDate" class="col-form-label"><spring:message code="shares.displacement.table.total.time" /></label>
                                <input id="displacementDate" name="displacementDate" type="datetime-local" class="form-control" required>
                            </div>
                        </div>
                    </div>
                    
                    <div class="row">
                        <div class="col-sm-12 col-md-6">
                            <label for="manualHours" class="col-form-label"><spring:message code="shares.displacement.total.time" /></label>
                            <input type="time" class="form-control" id="manualHours" name="manualHours">
                        </div>
                        
                        <div class="col-sm-12 col-md-6">
                            <label for="roundTrip" class="col-form-label"><spring:message code="shares.displacement.round.trip" /></label>
                            <input type="checkbox" class="form-control" id="roundTrip" name="roundTrip" style="width: 20px">
                        </div>
                    </div>
                    
                    <div class="row">
                        <div class="col">
                            <div class="form-group">
                                <label for="observations" class="col-form-label"><spring:message code="shares.displacement.observations" /></label>
                                <textarea id="observations" name="observations" class="form-control" rows="6"></textarea>
                            </div>
                        </div>
                    </div>
                    
                    <input type="hidden" class="form-control" id="projectId" name="projectId">
                </div>
                <div class="modal-footer clearfix">
                    <div class="w-100">
                        <div class="float-left">
                            <button type="button" class="btn btn-sm" data-dismiss="modal"><spring:message code="cerrar" /></button>
                        </div>
                        <div class="float-right">
                            <button id="updateDispBtn" type="button" class="btn btn-sm btn-success"><spring:message code="save" /></button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<!-- /CREATE MODAL -->
JavaScript:
$('#updateDispBtn').click(function () {
            
            $.ajax({
                type: "PUT",
                url: "/shares/displacement/" + id,
                data: $('#updateDispForm').serialize(),
                success: function(msg) {
                    $('#dTableSignings').DataTable().ajax.reload();
                    showNotify(msg, 'success');
                },
                error: function(e) {
                    showNotify(e.responseText, 'danger');
                }
            });
            $('#updateDispModal').modal('hide');
        });
