Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Работает с 3.1.1
- login_btn.onmousedown = function(e) {
- var link = document.getElementById('login_form').action;
- $.ajax({
- type: "POST",
- url: link,
- dataType: 'json',
- data: jQuery("#login_form").serialize(),
- // обработчик успешного ответа
- success: function (data, textStatus, jqXHR) {
- if(data.status === 'okmsg'){
- $("#div_form").fadeOut(0);
- }
- $('#'+data.status).text(data.msg);
- $("#"+data.status).fadeIn(500);
- setTimeout('hideMsgBlock()', 1000*6);
- },
- // обработчик ошибки
- error: function(xhr, status, error){
- $('.holder-loader').removeClass('open');
- console.log('ajaxError xhr:', xhr); // выводим значения переменных
- console.log('ajaxError status:', status);
- console.log('ajaxError error:', error);
- // соберем самое интересное в переменную
- var errorInfo = 'Ошибка выполнения запроса: '
- + '\n[' + xhr.status + ' ' + status + ']'
- + ' ' + error + ' \n '
- + xhr.responseText
- + '<br>'
- + xhr.responseJSON;
- console.log('ajaxError:', errorInfo); // в консоль
- // alert(errorInfo); // если требуется и то на экран
- }
- });
- };
- function hideMsgBlock (){
- $(".ajaxmsg").fadeOut(500);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement