title: Making ajax call to Strut2 action without page refresh
body: <p>I'm running Glassfish web server with Strut2 and I would like to pull json data from action class for a page without a page refresh.  What I mean by that is that when a user changes a setting I would like to show updated data automatically without page refresh.</p>
  
  <p>Making Ajax call to Strut2 action class seems to be my solution but all of my Google search resulted for the cases where page refresh is needed.</p>
  
  <p>Action class:</p>
  
  <pre><code>...
  @Override
  public String execute() throws Exception {
      result = "\"{\"age\":100,\"name\":\"dude\"}"; 
  
      return SUCCESS;
  }
  ...
  </code></pre>
  
  <p>strut.xml:</p>
  
  <pre><code>&lt;package name="default" namespace="/" extends="json-default"&gt;
      &lt;action name="getData" class="action.getData" method="execute"&gt;
          &lt;result type="json" /&gt;
      &lt;/action&gt;
  &lt;/package&gt;
  </code></pre>
  
  <p>ajax call:</p>
  
  <pre><code>jQuery.ajax(
  {
      type: 'POST', 
      url: '/proj/getData', 
      data: {id: $('#id').val()},
      dataType: 'json',
      contentType: 'application/json; charset=utf-8',
      success: function(data){         
          alert(data.result);
      },
      error: function(XMLHttpRequest, textStatus, errorThrown){
          alert('Error ' + textStatus);
          alert(errorThrown);
          alert(XMLHttpRequest.responseText);
      }
  }); 
  </code></pre>
  
  <p>Above code makes a correct call to correct function in the action class but two problems.</p>
  
  <ol>
  <li>I'm not sure how to pull the id data set in data section of ajax call in server side</li>
  <li><p>I get following error on server side on return.</p>
  
  <pre><code>WARNING: StandardWrapperValve[default]: PWC1406: Servlet.service() for servlet default threw exception
    java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils
    at org.apache.struts2.json.SerializationParams.&lt;init&gt;(SerializationParams.java:57)
    at org.apache.struts2.json.JSONResult.writeToResponse(JSONResult.java:207)
    at org.apache.struts2.json.JSONResult.execute(JSONResult.java:171)
  </code></pre></li>
  </ol>
  
  <p>I'm very new to strut2 and I know I have done similar things with ajax and struts but I just can't seem to figure this one out, so it would be appreciated if you can help.</p>