1.在ajax的success中设置setTimeout.
参照如下代码设置
$.ajax({
url: '{% url 'article:rename_article_column' %}',
type: 'POST',
data: {'column_id': column_id, 'column_name': new_name},
success: function (e) {
if (e === '1') {
{# 1秒钟后刷新页面,layer的msg弹窗消失 #}
setTimeout(function () {
parent.location.reload();
}, 1000);
layer.msg('good');
} else {
layer.msg('新的名称没有保存,修改失败。');
}
}
})
2.在ajax的success中实现页面跳转
示例代码如下:
$.ajax({
url: '{% url 'article:article_post' %}',
type: 'POST',
data: {'title': title, 'body': body, 'column_id': column_id},
success: function (e) {
if (e === '1') {
layer.msg('successful');
{# 成功实现了页面跳转 #}
parent.location = '/blog/';
} else if (e === '2') {
layer.msg('sorry')
} else {
layer.msg('有内容没有填写完整。')
}
}
})
网友评论