I am facing an issue with struts2+spring MVC+jquery Ajax. I have a struts2 action class with an Action "uploadLocationData". Here using annotation in struts 2.
@Action(value = "uploadLocationData", results = { @Result(name = "success",type = "json") })
public String insertLocationData() throws Exception {
String status = locationDao.insertLocationData();
if(status == "SUCCESS")
{
return SUCCESS;
}
else {
return ERROR;
}
}`
` and the ajax call :
function insertData(url,param)
{
$.ajax({
type: 'post',
url: url,
dataType: 'json',
success : function(data) {
console.log(data)
if (data == 'SUCCESS' || data == 'success') {
alert('Data inserted successfully!!!');
}
else if (data == 'ERROR' || data == 'error') {
alert('Data insertion Failed!!!');
}
},
error : function(data) {
alert('Data insertion Failed!!!');
},
});
}
the issue is, functionality is working but I didn't get the SUCCESS/ERROR response in ajax success/error part.
Please help me to fix this issue.