What does status=canceled for a resource mean in Chrome Developer Tools?

前端 未结 30 1976
温柔的废话
温柔的废话 2020-11-22 11:13

What would cause a page to be canceled? I have a screenshot of the Chrome Developer Tools.

\"Canceled

30条回答
  •  旧时难觅i
    2020-11-22 11:32

    In can this helps anybody I came across the cancelled status when I left out the return false; in the form submit. This caused the ajax send to be immediately followed by the submit action, which overwrote the current page. The code is shown below, with the important return false at the end.

    $('form').submit(function() {
    
        $.validator.unobtrusive.parse($('form'));
        var data = $('form').serialize();
        data.__RequestVerificationToken = $('input[name=__RequestVerificationToken]').val();
    
        if ($('form').valid()) {
            $.ajax({
                url: this.action,
                type: 'POST',
                data: data,
                success: submitSuccess,
                fail: submitFailed
            });
        }
        return false;       //needed to stop default form submit action
    });
    

    Hope that helps someone.

提交回复
热议问题