Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Cách 1
- $('#login-buttn').on('click', function () {
- $.ajax({
- type: 'POST',
- url: '/login',
- data: {
- username: $('#username').val(),
- password: $('#password').val()
- },
- dataType: 'json',
- async: false,
- success: function (response) {
- if (response.status == 'granted') {
- alert('Đăng nhập thành công');
- } else {
- alert('Đăng nhập thất bại');
- }
- }
- });
- });
- //Cách 2
- $('#login-form').submit(function(e) {
- $.ajax({
- type: 'POST',
- url: '/login',
- data: {
- username: $('#username').val(),
- password: $('#password').val()
- },
- dataType: 'json',
- async: false,
- success: function (response) {
- if (response.status == 'granted') {
- alert('Đăng nhập thành công');
- } else {
- alert('Đăng nhập thất bại');
- }
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement