Reputation: 1219
I am trying to send data using ajax
and retrieving the same in ajax
Here is my ajax
code
$.ajax({
url:"getSampleData",
type:'GET',
data : {'var':cellValue},
statusCode:{
404:function(data){
returnValue = data;
alert("This is 404 "+data.value);
},
403: function(data){
returnValue = data;
}
}
}
);
And In my struts.xml
I am catching like this.
<action name="getSampleData"
class="ActionClass"
method="sampleMethod">
<result name="success" type="httpheader" >
<param name="statusCode" >404</param>
</result>
<result name="fail" type="httpheader">
<param name="statusCode" >403</param>
</result>
</action>
In My action class
//Getters and setters for `var`
public String sampleMethod()
{
sysout("This is sample data "+getVar());//Here I am getting null value
}
Here My problem is I can get that cellValue
before I call ajax action but in my action class I am getting null value and as response I am making an alert call But I am unable to get that alert message.
Help would be appreciated , Thank You
Upvotes: 0
Views: 553
Reputation: 189
I'm not sure why you are getting null @ action method, check the property var is null or not.
In response you have to use
<param name="status" >403</param>
insted of
`<param name="statusCode" >403</param>`
please refer the link for more information HTTP Header Response
Upvotes: 1