سؤال

I have a Struts <s:submit> button in the form and when I click the button, the page should remain the same, so I added an onclick function to the submit button:

<s:submit action="product" method="loadsearch" id="find" onclick="return false"/>

Why is the submit button not triggering a submit?

هل كانت مفيدة؟

المحلول

To be on the same page needs to make Ajax call, as far as you using struts2-jquery plugin it's easy done via

place it on the JSP

<%@ taglib prefix="sj" uri="/struts-jquery-tags" %> 
<head>
 <sj:head/>
</head>

<s:div id="result"/>

<s:form action="product" method="POST"/>
  <sj:submit method="loadsearch" id="find" targets="result" />
</s:form>

نصائح أخرى

Because you return false which cancels submission.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top