javascript - 右大括号和圆括号

标签 javascript

问题

我组合了我一直在使用的三个独立的代码片段,但在关闭大括号和圆括号时遇到了问题。查看代码我怀疑它也可能不正确,尽管我不完全确定仍在学习 JavaScript 的过程中。

 $('#form1').submit(function(e) {
        var currentForm = this;
        e.preventDefault();
        bootbox.confirm("Are you sure?", function(result) {

            if (result) {

                console.log('Form Submitted'); //Debug line
        $.ajax({
            type: 'POST',
            url: 'indextest4.php',
            data: $("#form1").serialize(),
            error: function () {
                console.log('Ajax Error');}, //Debug Line

            success: function (response) {

                console.log('Ajax Success'); //Debug Line

                $('.fConfirm').css({
                display:"inline", 
                height: 680, 
                width: 940
                });

                console.log("After CSS change");

            }
        });

    });

此外,如果有好心人可以告诉我一个经验法则,告诉我当您关闭使用时我该如何锻炼?

}

})

});

最佳答案

正确的缩进在这里有很大帮助,因为之后一切都会很好地排列。以下是我认为您正在寻找的内容:

$('#form1').submit(function(e) {
    var currentForm = this;
    e.preventDefault();
    bootbox.confirm("Are you sure?", function(result) {
        if (result) {
            console.log('Form Submitted'); //Debug line
            $.ajax({
                type: 'POST',
                url: 'indextest4.php',
                data: $("#form1").serialize(),
                error: function () {
                    console.log('Ajax Error');
                }, //Debug Line

                success: function (response) {

                    console.log('Ajax Success'); //Debug Line

                    $('.fConfirm').css({
                        display:"inline", 
                        height: 680, 
                        width: 940
                    });

                    console.log("After CSS change");

                } // success: ...
            }); // $.ajax ...
        } // if (result) ...
    }); // bootbox.confirm ...
}); // $('#form1').submit ...

我在末尾对所有右大括号添加了注释以显示它们对应的内容。

关于javascript - 右大括号和圆括号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22338628/

相关文章:

javascript - 子组件如何在不监听生命周期方法的情况下从父组件接收 props?

javascript - 我如何等待 yield ?

javascript - 动画滚动到顶部 2

javascript - 从外部异步函数发送快速响应

JavaScript 无法加载 - html js

javascript - 带有 JavaScript 的 Html5 音频无法在 Chrome 以外的任何浏览器中运行

javascript - 从 json 数据中删除特定或选定的属性。我不想仅删除类别为 :null 的所有键值对

javascript - 如果某个字符较早出现,如何排除字符

javascript - Firebase 查询仅使用 endAt 方法获取节点

javascript - 文件上传ExtJS 4