我正在尝试解决自举模式弹出式窗口的问题。我在表单中有两个按钮,一个要取消,另一个要提交表单。如果我单击“取消”按钮,则仍会提交表单。谁能看到我要去哪里错了。
我的表格
<form name="DeleteConferenceBooking" id="Conference_Delete" method="post" autocomplete="off" enctype="multipart/form-data" role="form" data-toggle="validator">
<input name="RecordID" type="text" id="ConfDeleteRecordID">
<button type="button" class="tn btn-warning-edit btn-xs" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-secondary-edit btn-xs submit-button">Continue</button>
</form>
我的Jquery提交代码
$(document).ready (function () {
$('#Conference_Delete').on('click', function(e){
e.preventDefault();
$('#open_delete_conference_booking_data_modal').toggle();
var recordid = $('#ConfDeleteRecordID').val();
console.log("CONFERENCE DELETE RECORDID",recordid);
var form = this;
var formData = new FormData(form);
formData.append("RecordID", recordid);
$.ajax({
url: 'conf_bookings_delete.php',
type: 'POST',
data: formData,
cache: false,
contentType: false,
processData: false,
success: function(data){
var result = JSON.stringify(data);
result = JSON.parse(result);
console.log("RESULT", result);
$("#open_delete_conference_booking_data_modal").modal('hide');
$("#open_edit_data_modal").modal('hide');
$('#userTable').DataTable().ajax.reload();
}
});
});
});
非常感谢您的帮助和时间
将事件更改为提交,而不是单击。
$(document).ready (function () {
$('#Conference_Delete').on('submit', function(e){
e.preventDefault();
$('#open_delete_conference_booking_data_modal').toggle();
var recordid = $('#ConfDeleteRecordID').val();
console.log("CONFERENCE DELETE RECORDID",recordid);
var form = this;
var formData = new FormData(form);
formData.append("RecordID", recordid);
$.ajax({
url: 'conf_bookings_delete.php',
type: 'POST',
data: formData,
cache: false,
contentType: false,
processData: false,
success: function(data){
var result = JSON.stringify(data);
result = JSON.parse(result);
console.log("RESULT", result);
$("#open_delete_conference_booking_data_modal").modal('hide');
$("#open_edit_data_modal").modal('hide');
$('#userTable').DataTable().ajax.reload();
}
});
});
});