我有以下代碼:創建Grail Jquery模態窗口並使用ajax創建表單?
<body>
<div id="dialog-form" title="Create a new Comment">
<form>
<fieldset>
<label for="name">Enter your Comment Please </label>
<textarea rows="6" cols="2" name="commentArea" id="commentArea" ></textarea>
</fieldset>
</form>
</div>
<button id="create-user">Create new user</button>
</body>
和使用jQuery UI的
<g:javascript>
$(function(){
$("#dialog-form").dialog ({
autoOpen:false,
height:300,
resizable:false,
width:350,
modal:true,
buttons: {
"Attach Comment": function() {
alert('assum it already submitted'); // ? ? ? this time what can i add to post a form to a controller attachComments with commentArea posted.
$(this).dialog("close");
},
Cancel: function() {
$(this).dialog("close");
}
},
close: function() {
alert(Form is cloased!);
$(this).dialog("close");
}
});
$("#create-user")
.button()
.click(function() {
$("#dialog-form").dialog("open");
});
});
</g:javascript>
上面的代碼吸引我的模態窗口,但我怎麼能張貼的形式attachCommentController並接收返回的響應我的模態窗口在模態窗口上顯示錯誤?
你需要使用ajax向服務器發出請求而不刷新瀏覽器。然後,根據您收到的回覆,關閉模式或顯示錯誤。 – Gregg