javascript - What should I do if I want to continue the form submission behavior after jQuery blocks the form's default submission behavior?
漂亮男人
漂亮男人 2017-05-16 16:46:27
0
3
662

After jQuery blocks the default submission behavior of the form, what should I do if I want to continue the submission behavior?

The details are as follows:
A delete button, use sweetalert2 to prompt before submission. When the "Confirm" button in the prompt box is pressed, continue to submit the form.
html code:

<form action="/articles/{{ $article->id }}" method="POST">
    {{ method_field('DELETE') }}
    {{ csrf_field() }}
    <input class="btn btn-danger btn-sm need-alert" type="submit" value="删除">
</form>

js code:

    <script>
        $('.need-alert').on('click', function (event) {
            //阻止默认提交事件
            event.preventDefault();
            
            //sweetalert2的提示框代码:
            swal({
                title: '确定要删除吗?',
                text: '删除后不能恢复!',
                type: 'warning',
                showCancelButton: true,
                confirmButtonColor: '#3085d6',
                cancelButtonColor: '#d33',
                confirmButtonText: '确认删除'
            }).then(function () {
                
                
            }).catch(swal.noop);
        })
    </script>

After preventDefault() prevents the default submission event, the sweetalert2 prompt box can pop up normally.

Question:
After clicking "Confirm Delete" in the sweetalert2 prompt box, what should I write if I want to continue submitting this form?

漂亮男人
漂亮男人

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!