Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/472.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 Opencart quickview在添加购物车后关闭并重定向到当前页面_Javascript_Php_Jquery_Ajax_Opencart - Fatal编程技术网

Javascript Opencart quickview在添加购物车后关闭并重定向到当前页面

Javascript Opencart quickview在添加购物车后关闭并重定向到当前页面,javascript,php,jquery,ajax,opencart,Javascript,Php,Jquery,Ajax,Opencart,我使用的是opencart,我使用的主题具有产品快速查看功能,可以在弹出窗口中打开产品 如果我点击一个弹出窗口,产品被添加到购物车中,并且没有在外部页面中更新,但是如果我刷新了购物车更新的页面,我想在点击弹出窗口中的添加到购物车后重定向到当前url ajax post数据之后的jquery代码 success: function(json) { $('.alert, .text-danger').remove(); $('.form-group').rem

我使用的是opencart,我使用的主题具有产品快速查看功能,可以在弹出窗口中打开产品

如果我点击一个弹出窗口,产品被添加到购物车中,并且没有在外部页面中更新,但是如果我刷新了购物车更新的页面,我想在点击弹出窗口中的添加到购物车后重定向到当前url

ajax post数据之后的jquery代码

    success: function(json) {
        $('.alert, .text-danger').remove();
        $('.form-group').removeClass('has-error');

        if (json['error']) {
            if (json['error']['option']) {
                for (i in json['error']['option']) {
                    var element = $('#input-option' + i.replace('_', '-'));

                    if (element.parent().hasClass('input-group')) {
                        element.parent().after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
                    } else {
                        element.after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
                    }
                }
            }

            if (json['error']['recurring']) {
                $('select[name=\'recurring_id\']').after('<div class="text-danger">' + json['error']['recurring'] + '</div>');
            }

            // Highlight any found errors
            $('.text-danger').parent().addClass('has-error');
        }

        if (json['success']) {


            $('#notification').html('<div class="alert alert-success">' + json['success'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');

            $('#cart-total').html(json['total']);

            $('html, body').animate({ scrollTop: 0 }, 'slow');

            $('#cart > ul').load('index.php?route=common/cart/info ul li');
        }
    }
});
success:function(json){
$('.alert,.text danger').remove();
$('.form group').removeClass('has-error');
if(json['error']){
if(json['error']['option'])){
对于(json['error']['option']中的i){
变量元素=$('#输入选项'+i.replace('#','-');
if(element.parent().hasClass('input-group')){
(“”+json['error']['option'][i]+“”)之后的元素;
}否则{
元素之后(“”+json['error']['option'][i]+“”);
}
}
}
如果(json['error']['recurtive']){
$('select[name=\'recurtive\u id\']')。在(''+json['error']['recurtive']+'')之后;
}
//突出显示所有发现的错误
$('.text-danger').parent().addClass('has-error');
}
if(json['success']){
$('#notification').html(''+json['success']+'×;');
$('#购物车总数').html(json['total']);
$('html,body')。动画({scrollTop:0},'slow');
$('#cart>ul').load('index.php?route=common/cart/info ul li');
}
}
});
如果我使用window.location,则不会删除购物车弹出窗口

如果我使用
窗口.location.reload(true)在弹出窗口中刷新页面

$('#notification').html('<div class="alert alert-success">' + json['success'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');         

$('#cart-total').html(json['total']);

$('html, body').animate({ scrollTop: 0 }, 'slow');

$('#cart > ul').load('index.php?route=common/cart/info ul li');

alert('Product is Added to the cart');

window.open($('#request_url').text(),'_top');
我的网站链接是


单击产品图像或名称以显示左侧的快速查看弹出窗口

最后,我找到了解决方案,我在弹出窗口中获取文本中的上一个url 使用jquery获取它,并使用
窗口。location
,还可以使用
参数'\u top'
,该参数允许重定向到同一窗口并关闭弹出窗口

$('#notification').html('<div class="alert alert-success">' + json['success'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');         

$('#cart-total').html(json['total']);

$('html, body').animate({ scrollTop: 0 }, 'slow');

$('#cart > ul').load('index.php?route=common/cart/info ul li');

alert('Product is Added to the cart');

window.open($('#request_url').text(),'_top');
$('#notification').html(''+json['success']+'×;');
$('#购物车总数').html(json['total']);
$('html,body')。动画({scrollTop:0},'slow');
$('#cart>ul').load('index.php?route=common/cart/info ul li');
警报(“产品已添加到购物车”);
window.open($('request'u url').text(),'u top');