【发布时间】:2016-10-29 01:20:31
【问题描述】:
我正在尝试从 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;
}}
请帮帮我。
【问题讨论】:
-
尝试检查错误回调中的 textStatus,error 参数,这些参数将为您提供更多信息。另外我建议您也检查服务器日志。
-
在传递数据时,
data: ({caseId: caseId, noteID : noteID})中确实不需要圆括号。请删除它们(以(开头并以)结尾),您将不会收到任何错误。 -
检查this