title: Passing an array as a parameter in $.getJSON() method
body: <p>Hi I am trying to pass an array to Struts2 action class using jquery's getJSON() method but everytime its passing null elements.</p>
  
  <pre><code>var userIds=[];    
  </code></pre>
  
  <p>Then populating UserIds array with push() method:</p>
  
  <pre><code>$.getJSON('abc.action',{userArray:userIds}, function(json) {
                    for(var i=0;i&lt;json.returnMessages.length;i++){ 
                    alert(json.returnMessages[i]);
                    }
                });
  </code></pre>
  
  <p>Also , in the action class should i use array or arraylist will work as receiver variable.
  Please suggest ! Help is appreciated.</p>
  
  <p>Server-Side code:</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.List;
  
  
  import com.opensymphony.xwork2.Action;
  
  public class UserDetails {
  
      private static final long serialVersionUID = 1L;
      String[] userArray = new String[2];
  
  
  
      private List&lt;String&gt; returnMessages = new ArrayList&lt;String&gt;();
  
  
  
      public String[] getuserArray() {
          return userArray;
      }
      public void setuserArray(String[] userArray) {
          this.userArray = userArray;
      }
  
      public void setReturnMessages(List&lt;String&gt; returnMessages) {
          this.returnMessages = returnMessages;
      }
      public List&lt;String&gt; getReturnMessages() {
          return returnMessages;
      }
  
      public String execute() {
          try
          {  
  
  
  
              for (int i = 0; i &lt; userArray.length; i++) {
  
                  System.out.println("Success");
                  returnMessages.add("Success");
  
  
  
  
              }
  
  
           }
           catch (Exception e)
           {
              e.printStackTrace();
           }
  
  
  
  
          return Action.SUCCESS;
      }
  
  
  }
  </code></pre>