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