添加一個提交按鈕的形式,改變id屬性這麼容易與jQuery選擇它,重視處理
<s:form
id="deployChaptersForm"
action="%{deployChapterUrl}"
theme="simple"
method="POST">
<s:hidden name="nodeId" value"%{#chapterTree.nodeId}" />
<s:submit/>
</s:form>
<script type="text/javascript">
// Attach a submit handler to the form
$("#deployChaptersForm").submit(function(event) {
//Stop form from submitting normally
event.preventDefault();
//Get some values from elements on the page:
var $form = $(this),
value = $form.find("input[name='nodeId']").val(),
url = $form.attr("action");
//Send the data using post
var thePost = $.post(url, {nodeId: value});
//Handle results in data
thePost.done(function(data) {
alert(data);
});
});
</script>
THKS作出的貢獻:) – Stephan