Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.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
Javascript 通知显示完成后重新加载页面_Javascript_Jquery_Ajax_Toastr - Fatal编程技术网

Javascript 通知显示完成后重新加载页面

Javascript 通知显示完成后重新加载页面,javascript,jquery,ajax,toastr,Javascript,Jquery,Ajax,Toastr,这里有人吗?我如何修复我的通知?我想显示通知完全完成,然后重新加载页面。目前,我的通知很快退出,并且没有完全显示。我正在使用ajax和toastr。非常感谢各位!非常感谢你的帮助。以下是我尝试过的: function InsertOrUpdateExpense() { var data = $('#formExpenseTransaction').serialize(); $.ajax({ type : 'POST', url : url + 'I

这里有人吗?我如何修复我的通知?我想显示通知完全完成,然后重新加载页面。目前,我的通知很快退出,并且没有完全显示。我正在使用ajax和toastr。非常感谢各位!非常感谢你的帮助。以下是我尝试过的:

function InsertOrUpdateExpense() {
    var data = $('#formExpenseTransaction').serialize();
    $.ajax({
        type : 'POST',
        url : url + 'InsertOrUpdateExpenseTransaction',
        data : data,
        dataType : 'json',
        beforeSend:function() {
            $('#btn-expense--transaction').html(' <i class="icon-spinner2 spinner"></i>').attr('disabled',true);
        },
        success:function(data) {
            data.success === true ? notify(data.type,data.message) : notify(data.type,data.message);
            var content = data.type == 'info' ? 'Save Changes' : 'Add Expense';
            $('#btn-expense--transaction').html(content +' <i class="icon-arrow-right14 position-right"></i>').attr('disabled',false);
            setTimeout(function() {
                location.reload();
            }, 3000);
        }
    });
}

function notify(type,message) {
    Command: toastr[type](message)
}

function toastr_option() {
    toastr.options = {
        "newestOnTop": true, "progressBar": false, "positionClass": "toast-top-right", "preventDuplicates": true, "showDuration": 300, "hideDuration": 1000, "timeOut": 5000, "extendedTimeOut": 1000, "showEasing": "swing", "hideEasing": "linear", "showMethod": "slideDown", "hideMethod": "slideUp"
    }
}
函数InsertOrUpdateExpense(){
var数据=$('#formExpenseTransaction')。序列化();
$.ajax({
键入:“POST”,
url:url+“InsertOrUpdateExpenseTransaction”,
数据:数据,
数据类型:“json”,
beforeSend:function(){
$('#btn费用--交易').html('.attr('disabled',true);
},
成功:功能(数据){
data.success==true?通知(data.type,data.message):通知(data.type,data.message);
var content=data.type=='info'?'Save Changes':'Add Expense';
$(“#btn费用--交易”).html(内容+”).attr('disabled',false);
setTimeout(函数(){
location.reload();
}, 3000);
}
});
}
功能通知(类型、消息){
命令:toastr[type](消息)
}
函数toastr_option(){
toastr.options={
“newestOnTop”:true,“progressBar”:false,“positionClass”:“toast top right”,“preventDuplicates”:true,“showDuration”:300,“hideDuration”:1000,“timeOut”:5000,“extendedTimeOut”:1000,“showEasing”:“swing”,“hideEasing”:“linear”,“showMethod”:“slideDown”,“hideMethod”:“slideUp”
}
}

只需将location.reload()从setTimeout的内部移动到toastr的一个选项,名为“onHidden”

function toastr_option() {
    toastr.options = {
        "newestOnTop": true, "progressBar": false, "positionClass": "toast-top-right", "preventDuplicates": true, "showDuration": 300, "hideDuration": 1000, "timeOut": 5000, "extendedTimeOut": 1000, "showEasing": "swing", "hideEasing": "linear", "showMethod": "slideDown", "hideMethod": "slideUp", onHidden: function(){. location.reload(); }
    }
}

只需将location.reload()从setTimeout内部移动到名为“onHidden”的toastr选项

function toastr_option() {
    toastr.options = {
        "newestOnTop": true, "progressBar": false, "positionClass": "toast-top-right", "preventDuplicates": true, "showDuration": 300, "hideDuration": 1000, "timeOut": 5000, "extendedTimeOut": 1000, "showEasing": "swing", "hideEasing": "linear", "showMethod": "slideDown", "hideMethod": "slideUp", onHidden: function(){. location.reload(); }
    }
}

我不知道toastr,但是阅读时你可以尝试使用他的回调函数

在他的例子中:
toastr.options.onHidden=function(){console.log('bye');}

大概是这样的:

function toastr_option() {
    toastr.options = {
        "newestOnTop": true, "progressBar": false, "positionClass": "toast-top-right", "preventDuplicates": true, "showDuration": 300, "hideDuration": 1000, "timeOut": 5000, "extendedTimeOut": 1000, "showEasing": "swing", "hideEasing": "linear", "showMethod": "slideDown", "hideMethod": "slideUp"
    }
    toastr.options.onHidden = function() { location.reload(); }
}

我不知道toastr,但是阅读时你可以尝试使用他的回调函数

在他的例子中:
toastr.options.onHidden=function(){console.log('bye');}

大概是这样的:

function toastr_option() {
    toastr.options = {
        "newestOnTop": true, "progressBar": false, "positionClass": "toast-top-right", "preventDuplicates": true, "showDuration": 300, "hideDuration": 1000, "timeOut": 5000, "extendedTimeOut": 1000, "showEasing": "swing", "hideEasing": "linear", "showMethod": "slideDown", "hideMethod": "slideUp"
    }
    toastr.options.onHidden = function() { location.reload(); }
}

它还将重新加载我的页面,对吗?是的,当通知被隐藏时,将执行此属性onHidden。所以,一段时间后,页面将刷新!它还将重新加载我的页面,对吗?是的,当通知被隐藏时,将执行此属性onHidden。所以,一段时间后,页面将刷新!