Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. function auth() {
  2. var user = {
  3. login: $("#login").val(),
  4. password:$("#password").val(),
  5. }
  6.  
  7. $('#result').html('<div class="alert alert-block">Подождите...</div>');
  8.  
  9. $.ajax({
  10. url: '/file.php',
  11. type: 'post',
  12. dataType: 'json',
  13. success: function (data) {
  14. $("#result").empty();
  15. if (data.status == 'error') $('#result').html('<div class = "alert alert-error">'+data.msg+'</div>');
  16. if (data.status == 'ok') $('#result').html(data.msg);
  17. //$('#result').html(data.msg);
  18. },
  19. });
  20. }
  21.  
  22. $user = json_decode($user,true);
  23. if (!empty($user['login']) && !empty($user['password'])) {
  24. $data = array('status'=>'','msg'=>'ок, данные пришли');
  25. echo json_encode($data);
  26. } else {
  27. $data = array('status'=>'error','msg'=>'неправильно ввели пароль');
  28. echo json_encode($data);
  29. }
  30.  
  31. $.ajax({
  32. url: '/file.php',
  33. type: 'post',
  34. data: user,
  35. dataType: 'json',
  36. ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement