Advertisement
zero50x

JQ на CA

Apr 12th, 2018
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.73 KB | None | 0 0
  1. // Работает с 3.1.1
  2.     login_btn.onmousedown  = function(e) {
  3.         var link = document.getElementById('login_form').action;
  4.         $.ajax({
  5.             type: "POST",
  6.             url: link,
  7.             dataType: 'json',
  8.             data: jQuery("#login_form").serialize(),
  9.             // обработчик успешного ответа
  10.             success: function (data, textStatus, jqXHR) {
  11.                 if(data.status === 'okmsg'){
  12.                     $("#div_form").fadeOut(0);
  13.                 }
  14.                 $('#'+data.status).text(data.msg);
  15.                 $("#"+data.status).fadeIn(500);
  16.                 setTimeout('hideMsgBlock()', 1000*6);
  17.             },
  18.             // обработчик ошибки
  19.             error: function(xhr, status, error){
  20.                 $('.holder-loader').removeClass('open');
  21.  
  22.                 console.log('ajaxError xhr:', xhr); // выводим значения переменных
  23.                 console.log('ajaxError status:', status);
  24.                 console.log('ajaxError error:', error);
  25.                 // соберем самое интересное в переменную
  26.                 var errorInfo = 'Ошибка выполнения запроса: '
  27.                     + '\n[' + xhr.status + ' ' + status   + ']'
  28.                     +  ' ' + error + ' \n '
  29.                     + xhr.responseText
  30.                     + '<br>'
  31.                     + xhr.responseJSON;
  32.  
  33.                 console.log('ajaxError:', errorInfo); // в консоль
  34.                 // alert(errorInfo); // если требуется и то на экран
  35.             }
  36.         });
  37.     };
  38.     function hideMsgBlock (){
  39.         $(".ajaxmsg").fadeOut(500);
  40.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement