layui 非同步提交富文字編輯器內容
阿新 • • 發佈:2018-12-22
<script> layui.use('layedit', function(){ var layedit = layui.layedit; var index = layedit.build('demo'); //建立編輯器 $('#Btn').click(function () { layedit.sync(index); $.ajax({ type: "POST", url: '/Forum/AddInvitation/', data: $('#contact-form').serialize(), async: false, error: function (request) { layer.msg('未知錯誤,發表失敗', { icon: 2 }); }, success: function (json) { //判斷是否成功 if (json.result.result == "true") { document.getElementById("Btn").disabled = true; layer.msg(json.result.Word, { icon: 1 }); setTimeout(function () { location.reload(); }, 2000); } else if (json.result.result == "nologin") { layer.msg(json.result.Word); setTimeout(function () { window.location.href = '/Forum/Login' }, 2000); } else if (json.result.result == "error") { layer.msg(json.result.Word); } else { layer.msg('發表失敗!', { icon: 2 }); } } }); }); }); </script>