I have a select tag. s:selectinside a form. I want to send a post request to the action. I have struts 2 json plugin in place. I am not any in javascript or jquery.
<s:form action="selectFileType" method="post"
id="selectFileTypeForm">
<div>
<s:select id="select" headerKey=""
headerValue="%{getText('uploadAttachmentType.please.select')}"
name="uploadAttachmentType" list="attachmentTypeList"
required="true"
onchange="this.form.submit();"></s:select>
<s:hidden id="declarationObj_ideclare"
name="declarationObj.ideclare" />
<s:hidden id="declarationObj_completingpersonname"
name="declarationObj.completingpersonname" />
<s:hidden id="declarationObj_completingpersonofficaltitle"
name="declarationObj.completingpersonofficaltitle" />
<s:hidden id="declarationObj_completingpersonphone"
name="declarationObj.completingpersonphone" />
<s:hidden id="declarationObj_completingpersonext"
name="declarationObj.completingpersonext" />
</div>
</s:form>
`
Struts 2 has not good tools to perform ajax but you can send post request using jQuery only.
At first you need to find a target element in source code of rendered page and to make selector. It should look something like
select[name='searchEngine'] option:selected.Then you can write script that send value of your selected element to
destination_url. For example:See an example there and read getting started guide there.
That’s it.