js脚本部分
//自动学员登陆
$('.xs_right').each(function(){
var xy_isLogin = ($.cookie('snsCookieCheckUid')>0) ? true : false;
var jg_isLogin = ($.cookie('jgCookieCheckUid')>0) ? true : false;
if(xy_isLogin){
$.cookie('jgCookieCheckUid', null, { path: '/'});
$.ajax({
url:'http://k.thea.cn/index.php?c=login&a=ajaxuserinfo&callback=?',
type:'get',
dataType:'jsonp',
success:function(data){
if(data.flag=="ajaxok"){
$('.xs_log').show();
$('.xs_right').hide();
$('.xs_log').each(function(){
var $this = $(this);
var $zhic = $('.xsl_rank',$this);
var $i = 0;
var $k_url = data.dat.avatar;
if($k_url.indexOf('http') < 0){
$k_url = 'http://k.thea.cn' + $k_url;
}
$('.xsl_img img',$this).attr('src',$k_url);
//$('.xsl_img img',$this).attr('src',data.dat.avatar);
$('.xsl_img strong',$this).html(data.dat.username);
$('p .xsl_gold b',$this).html(data.dat.kcurrency);
$i = parseInt(data.dat.vip) ;
})
})
然后路径为http://k.thea.cn/index.php?c=login&a=ajaxuserinfo&callback后台部分:
public function ajaxuserinfo() { $callback = $_REQUEST["callback"]; if($this->memberId == 0) { echo $callback.'({"flag":"nologin","message":"请先登录!"})'; } else { $dat=$this->memcache->funGetUserInfo($this->memberId); $dat = $dat[0]; if($dat['uid']) { $r = array( 'flag' => 'ajaxok' ); $r['dat'] = $dat; echo $callback.'('.json_encode($r).')'; } else { echo $callback.'({"flag":"error","message":"抱歉,获取信息失败!"})'; } } } }
over了。