python--django实现升级公告的ajax源码

//增加公告

function addnote(){
    layer.open({
        type: 1,
        title:["新增升级公告"],
        skin: 'layui-layer-demo', 
        area: ['600px', '360px'],
        shadeClose: true, 
        content: '<textarea rows="3" cols="20" maxlength="64" id="noteinfo" style="margin-left:10px;margin-top:10px;width:580px;height:200px;resize:none;"></textarea>',
        btn:["确定","取消"],
        btn1:function(){
            var notes=document.getElementById("noteinfo").value;
            $.ajax({
                cache:false,
                type:"POST",
                url:"/addnote/",
                data:{'info':notes},
                async:true,
                beforeSend:function(xhr,settings){
                    xhr.setRequestHeader("X-CSRFToken","{{csrf_token}}");
                },
                success:function(data){
                    if(data.notecode=="success"){
                        window.layer.closeAll();
                        layer.msg("提交成功",{
                            time:1000
                        },function(){
                            window.location.reload();
                        });
                    }else{
                        layer.msg("提交失败");
                    }
                }
                
            })
        },
        btn2:function(){
            layer.msg("取消成功");
            return true;
        },
        });
};

 

 

 

//启禁公告
function turnnote(noteid){
    $.ajax({
        cache:false,
        type:"POST",
        url:"/ablenote/",
        data:{'noid':noteid},
        async:true,
        beforeSend:function(xhr,settings){
            xhr.setRequestHeader("X-CSRFToken","{{csrf_token}}");
        },
        success:function(data){
            if(data.scode==="success0"){
                layer.msg("禁用成功",{
                    time:1000
                },function(){
                    window.location.reload();
                });
            }else if(data.scode==="success1"){
                layer.msg("启用成功",{
                    time:1000
                },function(){
                    window.location.reload();
                });
            }else{
                layer.msg("请求错误",{
                    time:1000
                },function(){
                    window.location.reload();
                });
            }
            },
        })
};

已开流量主的小程序欢迎体验,还在完善中。。

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

py编程

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值