一个关于提示的栗子 noty

2020-01-10 16:403252

后端:


<?php

namespace app\portal\controller;

use cmf\controller\HomeBaseController;

class LiziController extends HomeBaseController
{
	public function index()
	{
		return $this->fetch();
	}
    public function aoligei()
    {
        $this->success('奥利给!');
    }
}


前端:

<html>

	<head>
		<title>一个关于提示的栗子</title>
		<script type="text/javascript">
			//全局变量
			var GV = {
				WEB_ROOT: "__WEB_ROOT__/",
				JS_ROOT: "static/js/"
			};
		</script>
		<script src="__STATIC__/js/wind.js"></script>
	</head>

	<body>

		<form class="js-ajax-form" action="{:url('portal/lizi/aoligei')}" method="post">
			<button type="submit">栗子</button>
		</form>

		<form method="post" id="lizi-form">
			<button type="submit" id="lizi-submit">异步栗子</button>
		</form>

		<script src="__STATIC__/js/jquery.js"></script>
		<script src="__STATIC__/js/frontend.js"></script>

		<!--异步栗子begin-->
		<script type="text/javascript">
			$('#lizi-submit').click(function() {
				$('#lizi-form').ajaxSubmit({
					url: "{:url('portal/lizi/aoligei')}",
					type: "post",
					success: function(data) {
						noty({
							text: data.msg,
							type: 'success',
							layout: 'topCenter',//top center topCenter
							modal: true
						});
					}
				});
				return false;
			});
		</script>
		<!--异步栗子end-->

	</body>

</html>


本栗子在ThinkCMF5.1下食用。


QQ截图20200110164329.png

上一篇: 在宝塔面板中安装ThinkCMF5.1 nginx配置伪静态

下一篇: ThinkPHP5.1的Log::write()