381 Star 2.5K Fork 616

GVPJohn / gf

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gpage_ajax.go 1.16 KB
一键复制 编辑 原始数据 按行查看 历史
John 提交于 2018-10-29 23:22 . 去掉gview.HTML
package main
import (
"gitee.com/johng/gf/g"
"gitee.com/johng/gf/g/os/gview"
"gitee.com/johng/gf/g/net/ghttp"
"gitee.com/johng/gf/g/util/gpage"
)
func main() {
s := ghttp.GetServer()
s.BindHandler("/page/ajax", func(r *ghttp.Request){
page := gpage.New(100, 10, r.Get("page"), r.URL.String(), r.Router)
page.EnableAjax("DoAjax")
buffer, _ := gview.ParseContent(`
<html>
<head>
<style>
a,span {padding:8px; font-size:16px;}
div{margin:5px 5px 20px 5px}
</style>
<script src="https://cdn.bootcss.com/jquery/2.0.3/jquery.min.js"></script>
<script>
function DoAjax(url) {
$.get(url, function(data,status) {
$("body").html(data);
});
}
</script>
</head>
<body>
<div>{{.page}}</div>
</body>
</html>
`, g.Map{
"page" : page.GetContent(1),
})
r.Response.Write(buffer)
})
s.SetPort(8199)
s.Run()
}
Go
1
https://gitee.com/johng/gf.git
git@gitee.com:johng/gf.git
johng
gf
gf
v1.4.7

搜索帮助

53164aa7 5694891 3bd8fe86 5694891