Reputation: 7953
i want to get a value through ajax call this is how i have done,
<input type="text" id="CIMtrek_CI_CER" name="CIMtrek_CI_CER" onblur="getProjectInfo()"/>
and this is what is my script,
function getProjectInfo(){
var cerNo = document.getElementById('CIMtrek_CI_CER').value;
$.ajax({
type: "POST",
url: "CIMtrek_Project_Information",
data: {
cerNo: cerNo
},
success: function (msg) {
alert("msg : "+msg);
document.getElementById('div_CIMtrek_CI_Used_By_ProjNo').innerHTML=msg;
}
});
}
and this is what is my spring method :
@RequestMapping(value = "/CIMtrek_Project_Information", method = RequestMethod.POST)
public String getProjectInfotmation(@RequestParam("cerNo") String cerNo,HttpServletRequest request,HttpServletResponse response) throws Exception {
System.out.println("cerNo : "+cerNo);
return cerNo;
}
controll goes to this method and prints the value also but it does not replicate in call back where i have assigned the value.
success: function (msg) {
alert("msg : "+msg);
document.getElementById('div_CIMtrek_CI_Used_By_ProjNo').innerHTML=msg;
}
when i have used firebug the response is HTTP Status 404 - /ProjectCapexMonitoring/WEB-INF/views/81723.jsp
81723
is the input i gave with this input .jsp
is added and gives this exception.
Please help me to fine what is the and resolve.
Best Regards.
Upvotes: 0
Views: 317
Reputation: 1902
If you are expecting json response and have jackson jars in your classpath
add @ResponseBody
to your method
change
@RequestMapping(value = "/CIMtrek_Project_Information", method = RequestMethod.POST)
public String getProjectInfotmation(@RequestParam("cerNo") String cerNo,HttpServletRequest request,HttpServletResponse response) throws Exception {
System.out.println("cerNo : "+cerNo);
return cerNo;
}
to
@RequestMapping(value = "/CIMtrek_Project_Information", method = RequestMethod.POST)
public @ResponseBody String getProjectInfotmation(@RequestParam("cerNo") String cerNo,HttpServletRequest request,HttpServletResponse response) throws Exception {
System.out.println("cerNo : "+cerNo);
return cerNo;
}
Upvotes: 1