16 lines
543 B
JavaScript
16 lines
543 B
JavaScript
document.addEventListener('DOMContentLoaded', () => {
|
|
$('#loginBtn').click(() => {
|
|
const username = $('#username').val();
|
|
const password = $('#password').val();
|
|
|
|
$.post('/auth/login', { username, password })
|
|
.done((data) => {
|
|
alert(data.message);
|
|
// Redirect to another page
|
|
window.location.href = '/inventory';
|
|
})
|
|
.fail((jqXHR) => {
|
|
alert('Login failed: ' + jqXHR.responseText);
|
|
});
|
|
});
|
|
}); |