Here is some of my code in HTML:
function loadDoc(){
var num = '{"empid": 45,"name": "gaurav","salary":566.55}';
$.ajax({
url: 'http://localhost:9029/addS',
method: 'POST',
data: num,
success: function(response){
console.log("response::::"+response);
$("#output").text(response);
},
error: function( jqXHR,textStatus, errorThrown){
console.log("Error askdjk");
console.log(jqXHR);
console.log(textStatus);
console.log(errorThrown);
}
});
}
And here is a snippet from my Java code:
@RequestMapping(value="/addS",method={RequestMethod.POST})
public String addEmployee(@RequestParam int empid,@RequestParam String name,@RequestParam double salary){
return "employee added successfully(Separate): "+name;
}
I'm encountering a 400 error and despite trying multiple solutions, I am unable to resolve it. Any help would be appreciated.