我正试图从jquery调用一个控制器。这里的每件事都运行正常,但是在ajax中它会显示错误提示。出了什么问题。
$.ajax({
type: 'POST',
url:'<%=request.getContextPath()%>/billing',
data: ({caseId: caseId, noteID : noteID}),
cache: false,
success: function(data){
alert("Success");
},
error: function(xhr, textStatus, error){
alert("Error occured.");
}
});
我的控制器
@RequestMapping(value = "/billing", method = RequestMethod.POST)
public String Billing(@RequestParam Long caseId,
@RequestParam Long noteID, HttpServletRequest request) throws Exception {
try{
----Some data base updation---
logger.debug("success ");
return "success";
} catch (Exception e) {
logger.error(e,e);
throw e;
}}
请帮助我。
答案 0 :(得分:0)
//你必须离开内容类型才能发送服务器端,请定义内容类型..
$.ajax({
type: "POST",
url: '@Url.Action("PerTGradeMastEdit", "Master")',
data: "{'Request':'" + request + "'}",
contentType: "application/json; charset=utf-8",
success: function (response) {
if (response != null) {
var strResponse = response;
var ProgramData = strResponse.split("/");
// response = ProgramData[0];programId
$('#txtPerGrade').val(ProgramData[0]);
$('#txtDesc').val(ProgramData[1]);
}
},
failure: function (msg) {
alert(msg);
window.location.href = '@Url.Action("INDEX", "AUTHORIZE")';
}
});`enter code here`