Reputation: 4525
I am sending ajax request to my action class in struts-2. The data has been sent successfully but I am not getting any response from action and jquery fail()
is running after completion instead of done()
.
I am getting the error:
HTTP Status 404 - /MyProject/viewMonitor/newjsp.jsp
Ajax request:
$.ajax({
type: "post",
url: "getCampData"
data: {campaignId: campaignId},
}).done(function(response) {
alert("Camp List : " + response.campList);
}).fail(function() {
alert("error");
});
struts action mapping:
<action name="*CampData" method="{1}" class="com.monitor.CampAction">
<result name="get">/viewMonitor/newjsp.jsp"</result>
</action>
My action class get() method:
public String get(){
System.out.println("Camp : " + campaignId);
String[] split = campaignId.split(", ");
campList.addAll(Arrays.asList(split));
System.out.println("Camp List : " + campList);
return "get";
}
Upvotes: 2
Views: 1010
Reputation: 38
In your struts action mapping, in your result tag :
<result name="get">/viewMonitor/newjsp.jsp"</result>
you have an extra doublequote "
at .jsp"</result>
, I think this is the problem that your ajax is not working.
Upvotes: 1