AJAX登入集成CAS的项目获取用户信息

前端之家收集整理的这篇文章主要介绍了AJAX登入集成CAS的项目获取用户信息前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<pre name="code" class="html"><!doctype html>
<html>
 <head>
  <title>获取与CAS集成项目的用户信息</title>
    <Meta http-equiv="X-UA-Compatible" content="IE=edge">
    <Meta charset="utf-8">
    <Meta content="yes" name="apple-mobile-web-app-capable">
    <Meta content="yes" name="apple-touch-fullscreen">
    <Meta content="telephone=no" name="format-detection">
    <Meta content="black" name="apple-mobile-web-app-status-bar-style">
    <Meta content="#ffffff" name="msapplication-TileColor">
    <Meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport">
	
 </head>

 <body>
	
	<div>hello</div>
	<script type="text/javascript" src="js/jquery-3.1.0.min.js"></script>
	<script type="text/javascript">
	
	var username="11";
	var password="111";
	var ctx="http://chenyongtu.gicp.net";
	var ctx_t=ctx+"/teenagers";
	var ctx_c=ctx+"/cas";
	var url_userinfo=ctx+"/teenagers/a/mobile/userInfoNew?mobileLogin=true"
	var _services="service="+ encodeURIComponent(ctx_t+"/a/myTest/testLogin");
	var casUrl=ctx_c+"/login?"+_services+"&get-lt=true&n="+new Date().getTime();
	
		
	$(document).ready( function(){	
		 
		 //getuserinfo(url_userinfo);
		getTL(casUrl);
		

	});
	
	function getTL(url){
	$.ajax({   
		url:url,type:'get',data:'',async : false,error:function(){   
		   alert('error');   
		},success:function(result){   
			console.log(result);
			var data="lt="+result.split("&")[0]+"&execution="+result.split("&")[1].replace("/\r\n/g","").replace("/\n/g","")+"&_eventId=submit&username="+username+"&password="+password+"&submit=%E7%99%BB%E5%BD%95";
			var services="service="+encodeURIComponent(ctx_t+"/a/cas");
			
			var url=ctx_c+"/login?"+services+"&"+data;
			console.log("url"+url);
			
			login(url);
			
		}
	});
}


function login(url){
	$.ajax({   
		url:url,type:'post',success:function(data){   
		   console.log(data);   
		   getuserinfo(url_userinfo);
		}
	});
}

function getuserinfo(url){

	$.get(url,function(data){
		console.log(data); 
	});

}

	</script>	 		
 </body>
</html>

猜你在找的Ajax相关文章