I will assume that you have already added this configuration to your struts.xml to provide support for the JSON format:
<action name="checkGoodsIsEnough" class="ClassOf_CheckGoodsIsEnough">
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="json">
<param name="enableSMD">true</param>
</interceptor-ref>
</action>
If so, be sure to convert the javascript object to JSON string format using:
var JsonParams = JSON.stringify(params);
And then try to make the mail call like this:
$.ajax({
type: 'post',
url: "checkGoodsIsEnough",
data: JsonParams,
dataType:"json",
async: true,
success: alert("success"),
error: function (jqXHR) {
alert(jqXHR.status);
}
});
Hope this help!
source
share