Guest User

Untitled

a guest
Jan 11th, 2017
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.25 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>TEst</title>
  5.     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
  6.  
  7.  
  8.     <script type="text/javascript">
  9.        
  10.     $(document).ready(function(){
  11.         $("#login").click(function(){
  12.                 var data = {};
  13.                 // data.username = $('#userName').val();
  14.                 // data.password = $('#pwd').val();
  15.                 data.username = "admin"
  16.                 data.password = "password"
  17.                 alert(JSON.stringify(data));
  18.                 $.ajax({
  19.                     type: "POST",
  20.                     url: "https://httpbin.org/post",
  21.                     data: JSON.stringify(data),
  22.                     contentType: "application/json; charset=utf-8",
  23.                     dataType: "json",
  24.                     success: function(data){
  25.                         console.log("suc")
  26.                         console.log(data)
  27.                     },
  28.                     failure: function(errMsg) {
  29.                         console.log("fail")
  30.                         console.log(errMsg)
  31.                     }
  32.                 });
  33.  
  34.  
  35.             });
  36.     });
  37.     </script>
  38. </head>
  39. <body>
  40.  
  41. <button id="login">Click me</button>
  42.  
  43. </body>
  44. </html>
Add Comment
Please, Sign In to add comment