weixin_33720078 2015-10-05 07:00 采纳率: 0%
浏览 643

ajaxComplete不触发

I have this problem where not all of my ajaxComplete calls are getting fired.

My Code

$(document)
.ajaxStart(function () {
    $.blockUI();
 })
.ajaxComplete(function () {
    $.unblockUI();
 });

Here's the code where ajaxComplete didn't fire :

$('body').on('click', '.actTimeSheetApprove', function () {
    var node = $(this).parents('tr');

    $.ajax({
        url: '/TimeSheet/Approve/',
        type: 'POST',
        context: this,
        data: {
            __RequestVerificationToken: fnGetToken(),
            id: $(this).data('id')
        },
        success: function (data) {
            if (data == 'success') {
                var table = $('#tblTimeSheetApprove').DataTable();
                table.row(node).remove().draw();
                console.log('SUCCESS'); //I already made sure this is called
            }
        }
    })
})

Note that I already make sure SUCCESS log is called.

Any idea why?

UPDATE :

Here's my controller

[HttpPost]
[ValidateAntiForgeryToken]
[ClaimAuthorize("Role", "Manager")]
public ActionResult Approve(int id)
{
    _uow.TimeSheet.Approve(id, User.Identity.Name);
    _uow.Save();
    return Content("success");
}

And here's my console log :

enter image description here

  • 写回答

2条回答 默认 最新

  • weixin_33675507 2015-10-05 07:08
    关注

    I guess that you have incorrect the "syntax" in the $.ajax call, you miss the complete...

    success !== complete

    https://api.jquery.com/Ajax_Events/

    With ajaxStart you can use load or ajaxSetup for make the request and define the behaviour of the success/error methods;

    Also for debug, try to ajaxStop() and see if everything works well.

    评论

报告相同问题?