I am trying to develop a struts 2 web application and sending data via Ajax but the console show an 500 (Internal Server Error). I have tried a log but no solution found. But the operation performed successfully in back end means my data is updated but the output is Internal Server Error Here is my code..
ajax function
function revertIbcData(mydata) {
var paNo = $(mydata).attr("rollNo");
var viNo = $(mydata).attr("idNo");
alert(paNo + " " + viNo);
$.ajax({
type: 'GET',
contentType: 'application/json; charset=utf-8',
dataType: "json",
url: "revert.do",
data: {rollNo: paNo, idNo: viNo},
success: function (data) {
alert(data.msg);
},
error: function (abc, cba, errorThrown) {
alert('Error: ' + errorThrown);
}
});
}
action code
public String revertData() {
try {
conn = connect.getConnection();
ibcDAO.revertIbcProcessDetail(conn, rollNo, idNo);
msg = "Detail of " + rollNo + " and " + idNo + " reverted successfully.";
System.out.println(msg);
return "success";
} catch (Exception e) {
e.printStackTrace();
return "success";
}
}
and struts.xml is
<action name="revert" class="pac.ProcessAction" method="revertData">
<result name="success" type="json"></result>
</action>
Try this:
Here "jsonString" should be a class level variable.