$('#loginModal').on('hidden.bs.modal', function () {
$('.alert').alert('close');
document.getElementById("loginForm").reset();
})
bs_alert = function() {}
bs_alert.alert = function(message, cls) {
$('#status').html('
')
}
bs_alert.warning = function(message) {
bs_alert.alert(message, 'warning')
}
bs_alert.danger = function(message) {
bs_alert.alert(message, 'danger')
}
bs_alert.info = function(message) {
bs_alert.alert(message, 'info')
}
/*$('#clickme').on('click', function() {
bs_alert.warning('Your text goes here');
});*/
//$(".alert").alert('close')
function submitFunction(){
// send ajax
$.ajax({
url: '/security/user.php', // url where to submit the request
type : "POST", // type of action POST || GET
dataType : 'json', // data type
data : $("#loginForm").serialize(), // post data || get data
success : function(result) {
console.log(result.Id);
if(result.status > 0){
//Oculta modal login
window.location = ''
bs_alert.info(result.msg);
$('#loginModal').modal('toggle');
}else{
bs_alert.danger(result.msg);
}
},
error: function(xhr, resp, text) {
console.log(xhr, resp, text);
}
})
}
$(document).ready(function(){
// click on button submit
$("#loginSubmit").on('click', submitFunction);
//$("#loginForm").submit(submitFunction);
$("#logoutSubmit").on('click', function(){
// send ajax
$.ajax({
url: '/security/logout.php', // url where to submit the request
type : "POST", // type of action POST || GET
//dataType : 'json', // data type
data : $("#loginForm").serialize(), // post data || get data
success : function(result) {
console.log(result.Id);
window.location = ""
if(result.status > 0){
//Oculta modal login
bs_alert.info("Desconectado");
$('#loginModal').modal('toggle');
}else{
bs_alert.danger("Desconectado");
}
},
error: function(xhr, resp, text) {
console.log(xhr, resp, text);
}
})
});
});