Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何在Hubspot Messenger()消息关闭后重新加载窗口?_Jquery_Asp.net Mvc_Http Delete_Hubspot - Fatal编程技术网

Jquery 如何在Hubspot Messenger()消息关闭后重新加载窗口?

Jquery 如何在Hubspot Messenger()消息关闭后重新加载窗口?,jquery,asp.net-mvc,http-delete,hubspot,Jquery,Asp.net Mvc,Http Delete,Hubspot,我正在编写一个MVC应用程序,我真的需要在消息(错误和成功)关闭后重新加载窗口。 我怎样才能做到这一点 实际上,我正在单击按钮尝试此代码,但运气不佳: Messenger().run({ successMessage: 'Record Removed!', errorMessage: 'Error', progressMessage: 'Removing record...', events: { "

我正在编写一个MVC应用程序,我真的需要在消息(错误和成功)关闭后重新加载窗口。 我怎样才能做到这一点

实际上,我正在单击按钮尝试此代码,但运气不佳:

    Messenger().run({
        successMessage: 'Record Removed!',
        errorMessage: 'Error',
        progressMessage: 'Removing record...',
        events: {
            "click": function () {
                window.location.reload();
            }
        }
    }, {
        method: 'DELETE',
        url: $(this).data('url'),
        error: function (jqXHR, textStatus, errorThrown) {
            return errorThrown;
        }
    });
要测试的代码笔:

不确定,但请尝试此操作

   Messenger().run({
        successMessage: 'Record Removed!',
        errorMessage: 'Error',
        progressMessage: 'Removing record...',
        events: {
            "click": function () {
                window.location.reload();
            }
        }
    }, {
        method: 'DELETE',
        url: $(this).data('url'),
        error: function (data) {
                 location.reload();
        },
        success: function (data) {
               location.reload();
         },

    });

我决定改变这个解决方案的方法。感谢@codenut的帮助! 使用这个代码,对我来说很有用

$(document).on('click', 'button.deleteButton', function (e) {
    var urlDelete = $(this).data('url');
    var table = $('#' + $(this).data('grid')).DataTable();

    Messenger().run({
        successMessage: 'Row removed!',
        progressMessage: 'Removing row...'
    }, {
        method: 'DELETE',
        url: urlDelete,
        error: function (jqXHR, textStatus, errorThrown) {
             return errorThrown;
        },
        complete: function () {
            table.ajax.reload();
        }
    });
});

谢谢@codenut,但是使用这种方法,重载会在ajax执行之前发生。再次感谢@codenut,使用这种新方法,在出现错误的情况下,MVC返回的特定消息不会显示。但是,如果成功呢?为什么有人对这篇文章投了否决票?这有什么问题?最好在代码中包含一些上下文/解释,因为这会使答案对OP和未来的读者更有用。不错,但错误时重新加载又如何呢。我已经中和了你的问题;)@codenut,使用这种方法,我只对受删除操作影响的网格进行了部分重新加载。您的帮助对这个解决方案至关重要!很高兴听到这个消息