title: How to pass result from action to ajax in Struts2
body: <p>I have the following action, I want to pass name to the ajax response. How could I do it ?</p>
  
  <pre class="lang-java prettyprint-override"><code>public class DatabaseAction extends ActionSupport{
  
      private String name;
  
  
      public void selectAll() {
          name="aa";
  
      }
      public void update() {
  
      }
      public void delete() {
  
      }
      public void add() {
  
      }
  
      public String getName() { return name; }
  
      public void setName(String name) { this.name = name;}  
  }
  </code></pre>
  
  <p>I am using JQuery to write the ajax:</p>
  
  <pre class="lang-js prettyprint-override"><code>$(document).ready(function(){
      $("#select").click(function() {
          $.ajax({
              url:"/db/database!selectAll.action",
              type:"POST",
              dateType:"JSON",
              success:function(name){
                  alert(name);
              }
          });
      });
      $("#delete").click(function() {
          alert("delete");
      });
  });
  </code></pre>
  
  <p>alert is invoked, but empty result is shown.</p>