title: How to call a method in Struts2 Action Class method with javascript
body: <p>We currently use the following javascript to submit the form when one of the field values change.</p>
  <pre><code>var url = &quot;project/location/myAction.action?name=&quot;+ lname ; 
  document.forms[0].action = url;
  document.forms[0].submit();
  </code></pre>
  <p>which calls the following Struts2 action</p>
  <pre><code>&lt;action name=&quot;myAction&quot; class=&quot;project.location.NameAction&quot;&gt;
      &lt;result name=&quot;success&quot; type=&quot;tiles&quot;&gt;myAction&lt;/result&gt;   
  &lt;/action&gt;
  </code></pre>
  <p>which then goes to the <code>execute()</code> method of the Action class <code>NameAction</code> where I have to check to see if the form was submitted from the javascript.</p>
  <p>I would prefer to call the <code>findName()</code> method in <code>NameAction</code> directly from the javascript.  In other words I want the javascript to act like the following jsp code.</p>
  <pre><code>&lt;s:submit method=&quot;findName&quot; key=&quot;button.clear&quot; cssClass=&quot;submit&quot; &gt;
  </code></pre>