title: Calling an action using Ajax URL in Struts 2
body: <p>I am trying to connect to my action class by using URL as below in Ajax. But its not going into my action class and even it is not showing the selected value by using <code>$("#selectedCountry").val()</code>.</p>
  
  <pre><code>function getstates(){           
      alert($("#selectedCountry").val());         
      $.ajax({
        type : "GET",
        url  : "/ThirdTask/selectstate.action",
        dataType : 'text',
        data : "name="+$("#selectedCountry").val(),
        success : function(){
          $('statesdivid').html();
        },
        error : alert("No values found..!!")
      });         
  }
  </code></pre>
  
  <p><strong>My JSP code as follows:</strong></p>
  
  <pre><code>&lt;s:select  name="selectedCountry"  list="{'india','china'}"  onclick="getstates();"/&gt;&lt;/div&gt;
  &lt;div id="statesdivid"&gt;
  &lt;s:if test="%{#request.selectedstatenames != null}"&gt; 
  &lt;s:select list="#request.selectedstatenames" name="selectedState"&gt;
  &lt;/s:select&gt;
  &lt;/s:if&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>My <code>struts.xml</code>:</strong></p>
  
  <pre><code>&lt;action name="selectstate.action" class="com.thirdtask.actions.SelectAction" method="selectstate"&gt;
   &lt;result name="success"&gt;selecttag.jsp&lt;/result&gt; 
  &lt;/action&gt;
  </code></pre>