Struts 2 action not returning desired result to Jquery Ajax call

Viewed 2240

I am calling an action from jQuery Ajax with the following code and it returns me complete code of JSP page. All I need is the array list that is defined in the action class.

dashboard.js

$.ajax({
 url : 'ELD/getAllDivisions',
 type : 'POST',
 dataType: 'text/javascript',
 success : function(data) {
   alert("success");
   var response = data;
   alert(response);
  });

DivisionAction.java

@Autowired
private DivisionService divisionService;

private List<DivisionModel> divisionList = new ArrayList<DivisionModel>();

public String getAllDivisions() {
    divisionList = divisionService.getAllDivisions();
    return SUCCESS;
}

struts.xml

<constant name="struts.devMode" value="true" />
<package name="DIVISION" namespace="/" extends="struts-default">
    <action name="getAllDivisions" method="getAllDivisions" class="foo.bar.DivisionAction">
        <result name="success">/jsp/users/AdminDashboard.jsp</result>
    </action> 

Response enter image description here

All I need is the array list being returned from the action class.

1 Answers
Related