对于这个怎么操作首先我们要在登录的ajax请求中把后端的数据保存到sessionstorage中,代码如下

登录ajax

 1 $.ajax({
 2     type:'post',
 3     url:xxxxxxxxx,
 4     dataType:"json",
 5     data:xx,
 6     async:true,//(false)
 7     success:function(res){
 8         if(res==200){
 9             location.href='这里跳转地址',
10             //下面这行代码就是将登陆成功后端接口的数据转成字符串因为是对象,然后存到session给key
11             sessionStorage.setItem('key',JSON.stringify(res));
12         }
13     }
14 })

其他页面

 1 $(document).ready(function(){
 2     if(str==null){
 3         // window.location.href="load.html";
 4     }else{
 5 //这里是获取到你session数据转换对象因为是字符串
 6         var obj=JSON.parse(sessionStorage.getItem(key));
 7         $.ajax({
 8             type: 'post',
 9             url:xxxxx,
10             dataType: "json",
11             data: {
12             //这里是你要拿的参数
13                 UnitGuid: obj.(参数)
14             },
15             async: true,
16             success: function (response) {
17                 if (response == 1000) { //如果返回值d
18                     成功
19                 } else (response== 2004) {
20                     // 返回值为2004   用户信息有误
21                   失败
22                 }
23         
24             }
25         })
26     }    

 

posted on 2019-12-06 11:28  小菟同学  阅读(927)  评论(0编辑  收藏  举报

……