Home Article jquery跨域及返回

jquery跨域及返回

Source:jquery跨域及返回 Release time:2020-08-14 Author:Mr.赵 Reading volume:37
js:
$(function(){ var url=window.location.href;
        $.ajax({
            type: "GET",
            url: "http://ip.zhaozhiqi.top/index/index/backs",
            data: {url:url},
            dataType: "jsonp",
            jsonp:'callback',
            success: function(data){ if(data.code==200){
                    window.location.href=""+data.url;
                }
            }
        });
});
$.ajax({ 
url: "{:url('login/login')}",
 data: {username: username,password:password},
 dataType:"json",
 type: "post",
 success: function (res) { 
if(res.code==200){ 
HuiFang.Funtishi(res.msg,res.url); return false;
        }else{
 HuiFang.Funtishi(res.msg); return false;
        }
    }
});
控制器:
 public function backs(){  header('Access-Control-Allow-Origin: *');  header('Access-Control-Allow-Headers: Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-Requested-With');  header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE');  header('Access-Control-Max-Age: 1728000');  $i=50;  if($i=40){    $res=array('code'=>200);  }else{    $res=array('code'=>201);  }  return $callbak. '(' . json_encode($res) . ')'; // jsonp   }
  
I want to comment
Leave a message
http://boke.zhaozhiqi.top/index.php/
User login
You have not written any reviews yet!
You have commented!
Can only praise once!
You have a collection!