前端
弹窗+Ajax提交
Ajax提交表单
HTML
CSS
滚动条
隐藏按钮边框
圆角
JavaScrip
layui表单与图片一起提交
本文档使用MrDoc发布
返回首页
-
+
弹窗+Ajax提交
2019年10月15日 11:09
admin
# layer弹窗 网址:http://layer.layui.com/ <script type="text/javascript" src="{% static 'js/layer.js' %}"></script> <script> function del_column(the,column_id){ var name = $(the).parents("tr").children("td").eq(1).text(); layer.open({ type: 1, skin: 'layui-layer-rim', //加上边框 area: ['420px', '240px'], //宽高 content: '<div style="text-align:center;padding:20px 20px 10px 20px;"><b>是否确定删除{'+name+'}栏目</b></div>' btn:['确定','取消'], yes:function(){ $.ajax( url:'{% url "article:del_column" %}', type:"POST", data:{"column_id":column_id}, success:function(e){ if(e=="1"){ parent.location.reload(); layer.msg("has been deleted"); }else{ layer.msg(删除失败"); } }, ) }, }); } </script> --- <script src="/static/lib/layui/layui.js"></script> <script> layui.use(['element', 'form', 'jquery', 'laydate'], function () { var element = layui.element; var table = layui.table; var form = layui.form; var $ = layui.jquery; var laydate = layui.laydate; laydate.render({ elem: '#birthday', type: "datetime" }); form.verify({ birthdayVerify: [/^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))(\s(([01]\d{1})|(2[0123])):([0-5]\d):([0-5]\d))?$/, '日期格式不正确'],}); form.on('submit(add)', function(data){ var id = {{ daozhang_info.id }}; var name = data.field.name; var mailaddr = data.field.mailaddr; if ( mailaddr != "{{ daozhang_info.mailaddr }}" ) { layer.open({ type: 1, skin: 'layui-layer-rim', //加上边框 //area: ['420px', '240px'], //宽高 content: '<div style="text-align:center;padding:20px 20px 10px 20px;"><b>检测到话术有更新<br>系统将会以新话术识别归属业务!</b></div>', btn:['确定','取消'], yes:function(){ //发异步,把数据提交给php $.ajax({ type: "post", url: "/auto/daozhang_edit_api", data:{ id:id, name:name, mailaddr:mailaddr, csrfmiddlewaretoken: $('[name="csrfmiddlewaretoken"]').val() }, success:function(data){ layer.alert("修改成功", {icon: 6},function () { // 获得frame索引 var index = parent.layer.getFrameIndex(window.name); //关闭当前frame parent.layer.close(index); }); }, error:function () { layer.msg("修改失败",{icon: 5}); } }) } }) } else { layer.msg("无数据修改",{icon: 5}) } return false; }); }) </script>
分享到: