Skip to content

Instantly share code, notes, and snippets.

@loveyunk
Created November 7, 2018 07:19
Show Gist options
  • Save loveyunk/9eb590ddae70c8eb279d0fa99f82992e to your computer and use it in GitHub Desktop.
Save loveyunk/9eb590ddae70c8eb279d0fa99f82992e to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>ONO登录</title>
<style>
.container {
display: flex;
flex-direction: column;
}
.login-btn {
width: 100%;
height: 45px;
line-height: 45px;
text-align: center;
cursor: pointer;
background: #ddd;
}
</style>
</head>
<body>
<div class="container">
<div>11</div>
<div>22</div>
<div id="login" class="login-btn">确认登录</div>
</div>
<script>
var oLoginBtn = document.getElementById('login');
oLoginBtn.addEventListener('click', function () {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304) {
alert(xhr.responseText);
} else {
alert("Request was unsuccessful:" + xhr.status);
}
}
}
xhr.open('get', '', true);
xhr.send(null);
}, false);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment