这是我的代码:

<s:form
     id="deployChapters%{#chapterTree.nodeId}"
     action="%{deployChapterUrl}"
     theme="simple"
     method="POST">
     <s:hidden name="nodeId" value"%{#chapterTree.nodeId}" />
</s:form>


我向Ajax提交了此表单。对于Firefox,不会发送隐藏字段nodeId。它与Chrome或IE一起使用。

如何要求FF发送隐藏字段?

最佳答案

向表单添加一个提交按钮,更改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>

关于java - 如何强制Firefox发送隐藏字段?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22713528/

10-09 04:44