Click here to Skip to main content
15,895,538 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
JavaScript
$('#btnDelete').click(function () {
                if (selectedEvent != null && confirm('Are you sure?')) {
                    debugger;
                    $.ajax({
                        type: "POST",
                        url: '/TimeTable/DeleteEvent',
                        data: { 'eventID': selectedEvent.eventID },
                        success: function (data) {
                            if (data.status) {
                                debugger;
                                //Refresh the calender
                                FetchEventAndRenderCalendar();
                                $('#myModal').modal('hide');
                            }
                        },
                        error: function () {
                            alert('Failed');
                        }
                    })
                }
            })



html code

<button id="btnDelete" class="btn btn-default btn-sm pull-right">
<span class="glyphicon glyphicon-remove"></span> Remove
</button>


TimeTable.cs

[HttpPost]
public JsonResult DeleteEvent(int eventID)
{
var status = false;
using (MahiCommerceEntities dc = new MahiCommerceEntities())
{
var v = dc.TimeTables.Where(a => a.Id == eventID).FirstOrDefault();
if (v != null)
{
dc.TimeTables.Remove(v);
dc.SaveChanges();
status = true;
}
}
return new JsonResult { Data = new { status = status } };
}

What I have tried:

it throws me an error 500 server not found
Posted
Updated 13-Feb-18 22:22pm
Comments
F-ES Sitecore 14-Feb-18 5:00am    
Put a breakpoint in your DeleteEvent method and step through it in the debugger, it is probably throwing an exception.

1 solution

 
Share this answer
 
Comments
Dheerajs975 14-Feb-18 4:33am    
Did you found any error in below code?
Richard MacCutchan 14-Feb-18 4:47am    
The problem is at the server end, you need to find out why it returns that bad status. Are you sure that URL value is correct?
Dheerajs975 14-Feb-18 7:27am    
it was correct and i already solved my error.. thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900