比如,你发表文章后,想关闭当前窗口,或者是跳转到其它页面,又或者是再接着提交其它相关数据,可以参考下面的代码进行处理 [![](https://img.kancloud.cn/e7/a1/e7a19a05d6b7392d3bac1cdef8d99175_1247x986.png)](https://img.kancloud.cn/e7/a1/e7a19a05d6b7392d3bac1cdef8d99175_1247x986.png) ~~~ {extend name="$member_style_layout" /} {block name="content"} {include file="member@common/form" /} <script type="text/javascript"> function post_err(res){ layer.alert(res.msg); } function post_ok(res){ var type = "{:input('fromtype')}"; var ext_id = "{:input('ext_id')}"; if(type=="msg" && ext_id!=""){ //来自圈子的群聊界面 layer.msg('红包创建成功'); setTimeout(function(){ if(self!=top){ parent.window.layer.closeAll(); }else{ window.location.href = res.url;//document.referrer; } },1000); /* layer.load(1,{shade: [0.7, '#393D49']}, {shadeClose: true}); var id = res.data.id; var content = "<div class='hack-hongbao' data-id='"+id+"' data-title='"+$("input[name='title']").val()+"'>红包来了!</div>"; $.post("/member.php/member/wxapp.msg/add.html",{ 'uid':"-{:input('ext_id')}", 'content':content, },function(res){ if(res.code==0){ layer.msg('红包创建成功'); }else{ alert(res.msg); } } );*/ }else{ setTimeout(function(){ window.location.href = res.url; },500); } } </script> {/block} ~~~ 其中 ~~~ var id = res.data.id; ~~~ 是获取到新增主题的ID ~~~ function post_ok(res) ~~~ 是发表成功的回调方法 ~~~ function post_err(res) ~~~ 是发表失败的回调方法