I have an ajax call to a web-api page (/api/attendances). Its inserting a record , and return OK() as a result.
Issue: insert is done correctly ,and OK will be returned, but instead of .done()/success() function, it calls .Fail()/error() .
I tried it in two ways ($.ajax() and $.Post()), both of them ends up with same result
1)
  $.post("/api/attendances", { gid: button.attr("data-gid") })
          .done(function () {
               alert("success...");
              })
          .fail(function () {
              alert("Something failed...");
              });
ServerSide Code:
2)
 public class AttendancesController : ApiController
  {
    //.........other initialize , ... codes in controller
   [HttpPost]
    public IHttpActionResult Attend(AttendDto dto)
    {
        //.....check for duplicate , ...
        var attendanceModel = new Attendance
        {
            AttendeeId = userId,
            gId = dto.gId
        };
        _context.Attendances.Add(attendanceModel);
        _context.SaveChanges();
        return Ok();
    }
}
3) Defining DTO
  public class AttendDto
    {
        public int  gId { get; set; }
    }
Any help would be appreciated.