I want to update record in database by using WEB API Controller
// PUT api/Student/5
[HttpPut]
public HttpResponseMessage PutStudent(int id, [FromBody]Student student)
{
//body
}
then how should I call this method using jquery ajax put method?
Loading
Tanmay MulePosted Feb 11, 2015, 7:26 AM
Pranay RanaPosted Feb 11, 2015, 7:12 AM
Tanmay MulePosted Feb 11, 2015, 7:09 AM
even the execution doesn't reach to my controllers method
Pranay RanaPosted Feb 11, 2015, 7:04 AM
Pranay RanaPosted Feb 11, 2015, 6:49 AM
var student = new Object();
student =
{
FirtName : 'John',
LastName : 'Smith'
};
$.ajax(
{
url: 'api/Student/PutStudent/' + id,
type: 'Put',
contentType : "application/json"
data: JSON.stringify(datasend),
dataType: "json",
success: function(result)
{
// Do something with the result
}
});
Type: String
The type of request to make (e.g. "POST", "GET", "PUT"); default is "GET".
Check jquery document : http://api.jquery.com/jQuery.ajax/#options for more details