跨域自动登录
Posted lovedaodao
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了跨域自动登录相关的知识,希望对你有一定的参考价值。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"> </script> </head> <body> <a href="#" onclick="goto()">点击跳转</a> <script type="application/javascript"> function goto() { var url = "http://www.bidchance.com/logon.do"; var userid = "xxxxx"; var pwd = "yyyyy"; var url_to = "http://www.bidchance.com/info-gonggao-30138261.html"; $.ajax({ url: url, type: "post", data: { userid: userid, pwd: pwd }, dataType: ‘jsonp‘, // 跨域访问 crossDomain: true, success: function (msg) { console.log(msg); }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log(XMLHttpRequest.status); console.log(XMLHttpRequest.readyState); console.log(textStatus); if (XMLHttpRequest.readyState == 4) { // 响应完成 window.open(url_to); } } }); } </script> </body> </html>
以上是关于跨域自动登录的主要内容,如果未能解决你的问题,请参考以下文章