html页面之间相互传值
常见的在页面登录过后会获得一个token值然后页面跳转时传给下一个页面
sessionStorage.setItem("token",result.token);//传输token
一班我们再建一个公共的文件来放置
var host = window.location.protocol + "//" + window.location.host;//获得页面ip和端口号
var token = "";
var t = sessionStorage.getItem("token");接收token
if (t != null) {
token = t;
}
别的页面
$.ajax({
type: "post",
url: host + "/dcms/api/v1/admin/login",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify({
"account": accounts,
"passwd": passwd
}),
success: function (result) {
//console.log(result.token);
sessionStorage.setItem("token",result.token);//传值给下一个页面
if (result.adminType == 1) {
window.location.href = "logadmin/index.html";
}
if (result.adminType == 2) {
window.location.href = "systemadmin/index.html";
}
if (result.adminType == 3) {
window.location.href = "secadmin/index.html";
}
if (result.code != 0) {
//"账号或者密码错误,请检查后重新登录!"
$(".content").text(result.msg);
}
},
error: function (result) {
showGlobleTip("服务器异常,请联系管理员");
}
});
最新文章
- MyCat源码分析系列之——BufferPool与缓存机制
- google protobuf安装与使用
- 服务器使用FTP命令行 无法传送文件 卡在150 Opening data channel for file transfer
- 一个";如何使用示波器安全测试接市电电路板";的问题
- html中button自动提交表单?
- PHP生成迅雷、快车、旋风等软件的下载链接代码实例
- jQuery源码分析之=>;jQuery的定义
- implement ";slam_karto"; package in Stage simulation
- 打包python脚本为exe可执行文件-pyinstaller和cx_freeze示例
- linux的fork函数
- git操作回顾:
- ecshop模板如何修改详细图解
- 在msvc中使用Boost.Spirit.X3
- css 相关
- centos7.2部署最新ELK 5.3
- Archive for required library:xxxxx/spring-beans-3.2.4.RELEASE.jar in project XXXXX cannot be read or is not a valid ZIP file
- mysql基础之yum安装mysql5.7.18
- Markdown文本测试
- leetcode算法:Distribute Candies
- jQuery实用工具集