1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
| var updateurl $('#updatemodal').on('show.bs.modal', function (event) { var button = $(event.relatedTarget) updateurl = button.data('url')
var modal = $(this) }) $(".modal-footer button[type='submit']").click(function(e){ e.preventDefault(); if (!$("#updateForm").valid()) { return false; }; var formData = $("#updateForm").serialize(); console.log('updateurl'+updateurl) $.ajax({ url: updateurl, type: "POST", data: formData, dataType: "json", success: function(data){ if (data.result === 0) { $("#updatemodal").modal('hide') toastr.success('成功:'+data.message) setTimeout(function() { $('#eventtable').DataTable().ajax.reload();
}, 1000) } else if (data.result === 1) { toastr.error('失败:'+data.message) } }, error: function(){ console.log("Error"); } }); });
$('#updateForm').validate({ rules: { detail_title: { required: true, minlength: 5 }, }, messages: { detail_title: { required: "请输入更新标题", }, }, errorElement: 'span', errorPlacement: function (error, element) { error.addClass('invalid-feedback'); element.closest('.form-group').append(error); }, highlight: function (element, errorClass, validClass) { $(element).addClass('is-invalid'); }, unhighlight: function (element, errorClass, validClass) { $(element).removeClass('is-invalid'); } });
|