ajax请求接口账号密码,ajax请求接口

简介这篇文章主要介绍了ajax请求接口以及相关的经验技巧,文章约839字,浏览量199,点赞数8,值得推荐!

$.ajax({

type:"post",

url:"http://192.168.0.63:81/api/activity/app/getActivityDetail?token=1&userId=1&sign=1", //填写接口地址

contentType:‘application/json‘,

data:JSON.stringify({

activityId:1

}),

// dataType: "json", //可选项

success: function(data){

console.log(data)

}

});

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
A: <!DOCTYPE html> <html> <head> <title>Login Page</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Include Bootstrap stylesheet --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <!-- Include jQuery library --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!-- Include Bootstrap javascript --> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <script> $(document).ready(function(){ $("#login_btn").click(function(){ var username = $("#username").val(); var password = $("#password").val(); $.ajax({ url: "backend.php", type: "POST", data: {username:username, password:password}, success: function(response){ if(response == "success"){ window.location.href = "home.html"; }else{ alert("Invalid username or password!"); } }, error: function(){ alert("Error occured while processing request!"); } }); }); }); </script> </head> <body> <div class="container"> <h2>Login</h2> <form> <div class="form-group"> <label for="username">Username:</label> <input type="text" class="form-control" id="username" placeholder="Enter username"> </div> <div class="form-group"> <label for="password">Password:</label> <input type="password" class="form-control" id="password" placeholder="Enter password"> </div> <button type="button" class="btn btn-primary" id="login_btn">Submit</button> </form> </div> </body> </html> Note: This is just an example HTML code. You need to replace backend.php with your actual backend URL and implement the backend API for processing login credentials. Also, make sure to implement proper security measures to prevent attacks like SQL injection and XSS.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值