JSP/JQuery call:-
$.ajax({
url: "ApplyCouponCode",
type: "POST",
data: {couponCode: $('#PaymentMethod_couponCode').val()},
dataType: "json",
error: function(){
alert('Error');
},
success: function(data){
alert('SUCCESS');
$('#spanValidatedCoupon').text('Is coupon valid? ' + data.couponIsValid + ' couponAmount = ' + data.couponAmount);
}
});
Action Class:
public String applyCouponCode() throws Exception {
if(logger.isDebugEnabled()){
logger.debug("data: couponCode '" + couponCode + "'");
}
return SUCCESS;
}
The Action class method [applyCouponCode] is invoked. But couponCode is null.. please advise. couponCode has public getter/setter methods .. what else do i need to do?
I think your action method should take couponCode as a parameter. Assuming couponCode is type string, your action method should look something like this:
Hope this helps.