Created
January 6, 2016 11:02
-
-
Save fearrr/bf8325dd90d6b1267c9b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//AJAX AUTH | |
$.ajaxSetup({ | |
headers: { | |
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') | |
} | |
}); | |
var login = $('#log-in'); | |
var loader = $('#progress-load'); | |
var url = login.attr('action'); | |
var sbtn = $('#login-submit'); | |
login.submit(function(e){ | |
e.preventDefault(); | |
var data = login.serializeArray(); | |
$.ajax({ | |
type: 'POST', | |
url: url, | |
cache: false, | |
dataType: 'json', | |
beforeSend: function(){ | |
loader.show(); | |
sbtn.css({opacity: 0.2}); | |
}, | |
data: data, | |
success: function(data){ | |
loader.hide(); | |
sbtn.css({opacity: 1}); | |
alert(data); | |
/* | |
if(data.success == false) | |
{ | |
var arr = data.errors; | |
$.each(arr, function(index, value) | |
{ | |
if (value.length != 0) | |
{ | |
toastr.info(value); | |
} | |
}); | |
} else { | |
toastr.success('Успешно! Сейчас Вы будете перемещены в панель!'); | |
window.location.href = "personal/dashboard"; | |
} | |
*/ | |
}, | |
error: function(data){ | |
loader.hide(); | |
sbtn.css({opacity: 1}); | |
var errors = $.parseJSON(data.responseText); | |
$.each(errors, function(index, value) { | |
toastr.error(value); | |
}); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment