| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- <script src="js/axios.min.js"></script>
- </head>
- <body>
- <form action="#" >
- 账号: <input type="text" name="username" id="username"><br>
- 密码: <input type="password" name="password" id="password"><br>
- <input type="button" value="登录" onclick="get()">
- </form>
- <button onclick="get()">get</button>
- <button onclick="post()">post</button>
- </body>
- <script>
- /**
- * http://c46a5489.natappfree.cc/login
- * 需求: 使用get 请求调用/login 接口
- * 使用post 调用/login1 接口
- */
- function get(){
- var username = document.getElementById("username").value
- var password = document.getElementById("password").value
- axios({
- method: "get",
- url: "http://c46a5489.natappfree.cc/login",
- params: {"username":username,"password":password}
- }).then(function (result) {
- if(result.data.success){
- alert("登录成功")
- }else{
- alert("登录失败")
- }
- })
- }
- function post(){
- var username = document.getElementById("username").value
- var password = document.getElementById("password").value
- axios({
- method: "post",
- url: "http://c46a5489.natappfree.cc/login1",
- data: {"username":username,"password":password}
- }).then(function (result) {
- if(result.data.success){
- alert("登录成功")
- }else{
- alert("登录失败")
- }
- })
- }
- </script>
- </html>
|