我有如下表格
<form id="myform" class="form-horizontal" class="collapse in">
<fieldset>
<!-- form fields are here -->
<div class="form-actions">
<button class="btn btn-inverse" id="search" name="search" data-loading-text="Searching...">Search</button>
</div>
</fieldset>
</form>
一旦按下按钮,我将使用以下代码执行操作:
$("#search").click(function() {
try {
// some javascript with syntax error is here
} finally {
return false; // don't submit form automatically
}
});
但是如果我的 javascript 包含语法错误,那么无论try .. finally
. 我该如何解决?表单不应自动提交。