设为首页 加入收藏

TOP

Beego 学习笔记12:文件的操作(二)
2017-12-11 09:18:58 】 浏览:939
Tags:Beego 学习 笔记 文件 操作
trap/css/bootstrap.css"/> <script type="text/java script" src="/static/js/jquery-2.1.1.min.js"></script>  <script type="text/java script" src="/static/bootstrap/js/bootstrap.min.js"></script>        </head>         <body> <div class="container"> <!--创建text文件--> <div style="width:100%;height:50px;"> <button onclick="createtxt()" class="btn btn-primary">创建text文件</button> <label id="txtname"></label> </div> <!--写入文件--> <div style="width:100%;height:300px;margin-top:20px;"> <label>输入内容:</label> <textarea id="writeinfo" style="width:50%;height:200px;" class="form-control"></textarea> <button value="写入内容" onclick="txtwrite()" class="btn btn-primary" style="margin-top:20px;">写入内容</button> </div> <!--读取文件内容部分--> <div style="width:100%;height:300px;"> <button value="读取内容" onclick="txtread()" class="btn btn-primary" style="margin-bottom:20px;">读取内容</button> <textarea id="readinfo" style="width:50%;height:200px;" class="form-control" ></textarea> </div> <button onclick="deletetxt()" class="btn btn-primary">删除text文件</button> </div> <!--JS部分--> <script type="text/java script"> //创建text文件 function createtxt(){ $.ajax({ type:'post', url:'/Home/FileCreate', data:{}, success:function(result){ console.log('获取的数据') console.log(result) $("#txtname").html(result.data); } }) } //写入文件的内容 function txtwrite(){ $.ajax({ type:'post', url:'/Home/FileWrite', data:{ "info":$("#writeinfo").val(), "path":$("#txtname").html() }, success:function(result){ console.log('获取的数据') console.log(result) $("#showinfo").html(result.data); } }) } //读取文件的内容 function txtread(){ $.ajax({ type:'post', url:'/Home/FileRead', data:{ "path":$("#txtname").html() }, success:function(result){ console.log('获取的数据') console.log(result) $("#readinfo").html(result.data); } }) } //删除text文件 function deletetxt(){ $.ajax({ type:'post', url:'/Home/FileDelete', data:{ "path": $("#txtname").html() }, success:function(result){ console.log('获取的数据') console.log(result) if(result.data){ $("#txtname").html(''); alert("删除成功"); }else{ alert("删除失败"); } } }) } </script>     </body> </html>

  

5>     在路由器router.go中添加路由.具体代码如下:

package routers

import (
	"secondweb/controllers"
	"github.com/astaxie/beego"
)

func init() {
	beego.Router("/", &controllers.MainContro
首页 上一页 1 2 3 下一页 尾页 2/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Beego 学习笔记14:Session控制 下一篇Beego 学习笔记10:Easyui使用

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目