Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>TEst</title>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
- <script type="text/javascript">
- $(document).ready(function(){
- $("#login").click(function(){
- var data = {};
- // data.username = $('#userName').val();
- // data.password = $('#pwd').val();
- data.username = "admin"
- data.password = "password"
- alert(JSON.stringify(data));
- $.ajax({
- type: "POST",
- url: "https://httpbin.org/post",
- data: JSON.stringify(data),
- contentType: "application/json; charset=utf-8",
- dataType: "json",
- success: function(data){
- console.log("suc")
- console.log(data)
- },
- failure: function(errMsg) {
- console.log("fail")
- console.log(errMsg)
- }
- });
- });
- });
- </script>
- </head>
- <body>
- <button id="login">Click me</button>
- </body>
- </html>
Add Comment
Please, Sign In to add comment