javascript - JQuery Ajax Success not being triggered -
i'm not sure why ajax success isn't being triggered/called. controller called , code executed fine. i'm not returning anything, method void! need return (actionresult/jsonresult/etc) success trigger?
here controller code.
public void deleteevent(string eventid) { diaryeventservice.deletediaryevent(eventid); }
here ajax call.
$.ajax({ url: '/managespaces/deleteevent', datatype: 'json', data: { eventid: eventid, }, success: function() { //var obj = json.parse(doc); var mycalendar = $('#fullcalendar'); mycalendar.fullcalendar(); mycalendar.fullcalendar('removeevents', eventid); $("#eventdetails").collapse('toggle'); } });
yes, need return jsonresult
:
[httppost] public jsonresult deleteevent(string eventid) { diaryeventservice.deletediaryevent(eventid); return json("{status:"ok"}"); }
since changing back-end data, set post:
$.ajax({ url: '/managespaces/deleteevent', method: 'post', datatype: 'json', data: { eventid: eventid, }, success: function(response) { if(response.status=="ok"){ var mycalendar = $('#fullcalendar'); mycalendar.fullcalendar(); mycalendar.fullcalendar('removeevents', eventid); $("#eventdetails").collapse('toggle'); }else{ console.log("error occured") } } });
Comments
Post a Comment