$(document).ready(function() {
$('#log-button').click(function(e) {
e.preventDefault();
var data = new FormData($('#loginForm')[0]);
$.ajax({
url: "ajax-login.php",
type: "POST",
data:data,
processData: false,
contentType: false,
success: function(data)
{
var msg = "";
var succsess='<meta http-equiv="refresh" content="0; url='+ document.location.origin + '/setSession.php">';
if (data === 'ok') {
$("#log-message").html(succsess);
}
else {
msg = "Invalid username or password!";
}
$("#log-message").html(msg);
}
});
});
});
url: "ajax-login.php",
type: "POST",
data:data,
processData: false,
contentType: false,
error: function(jqXHR, exception) {
if (jqXHR.status === 0) {
alert('Not connect.\n Verify Network.');
} else if (jqXHR.status == 404) {
alert('Requested page not found. [404]');
} else if (jqXHR.status == 500) {
alert('Internal Server Error [500].');
} else if (exception === 'parsererror') {
alert('Requested JSON parse failed.');
} else if (exception === 'timeout') {
alert('Time out error.');
} else if (exception === 'abort') {
alert('Ajax request aborted.');
} else {
alert('Uncaught Error.\n' + jqXHR.responseText);
}
},
success: function(data){