获取页面代码的方法,并保存到后端
function submitHandler() {
//获取html代码
var html=$('#table').html();
//提交到后台,基于若依框架
$.operate.save(prefix + "/add", {html:html});
}
上面的save方法实现
save: function(url, data, callback) {
var config = {
url: url,
type: "post",
dataType: "json",
data: data,
beforeSend: function () {
$.modal.loading("正在处理中,请稍后...");
$.modal.disable();
},
success: function(result) {
if (typeof callback == "function") {
callback(result);
}
$.operate.successCallback(result);
}
};
$.ajax(config)
}
调用接口显示页面
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('修改出行气象')" />
<style>
input{
width:100%;
border:none;
text-align: center;
outline-color: #FFFFFF;
}
span{
display: inline-block;
width:25%;
text-align: center;
}
#table{
width:80%;
margin: 10px auto;
}
</style>
</head>
<body class="white-bg">
<input type="hidden" id="id" th:value="${gsWeather.id}">
<div id="table" class="container-div" th:utext="${gsWeather.html}">
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
//将表格设置呈只读
$('input').attr('readonly',true)
</script>
</body>
</html>