こんにちは、私はこのフォームを含む単純な html ページを持っています:
<form:form method="post" action="details" modelAttribute="code">
<form:input path="code"/>
<br/>
<input type="submit" value="Submit" />
</form:form>
[送信] ボタンを押すと、jQuery AJAX を使用して、特定のコードのデータベースにレコードがあるかどうかを確認する必要があります。はいの場合は、jQuery UI ダイアログをポップアップして、レコードの詳細を本当に表示するかどうかをユーザーに尋ねます (有料サービスであるため)。彼が確認したら、フォームを提出する必要があります。これはhtmlページの私のスクリプトです:
$(document).ready(function() {
// Bind an event handler to the submit event
$('form#code').submit( function() {
// Check whether there are some records in the DB using AJAX
$.ajax({
url: 'getResultCount',
type: 'post',
dataType: 'html',
data: $("form#code").serialize(),
success: function(result) {
if(result == 'null') {
$('div#results').html('<p>No records found for ' + $('input#code').val() + '.</p>');
} else {
// At leat one record was found so ask the user
$('#dialog-confirm').dialog({
resizable: false,
draggable: false,
height: 240,
width: 450,
modal: true,
buttons: {
"Display details": function() {
// User confirmed, submit the form
$('form#code').submit();
},
Cancel: function() {
$(this).dialog("close");
}
}
});
}
}
});
return false;
});
});
「詳細表示」ボタンを押しても何も起こりません。falseを返す同じ送信ハンドラーを入力しているためだと思います。フォーム送信が実行されるように解決するにはどうすればよいですか? お知らせ下さい。前もって感謝します。ヴォイテック