File size: 883 Bytes
0dff816 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
// filepath: /jmotors/jmotors/src/assets/js/scripts.js
document.addEventListener('DOMContentLoaded', function() {
// Function to handle logout
function handleLogout() {
fetch('logout.php', {
method: 'POST'
})
.then(response => response.json())
.then(data => {
if (data.success) {
window.location.href = 'pages/home.php';
} else {
alert(data.message);
}
})
.catch(error => console.error('Error:', error));
}
// Event listener for logout button
const logoutButton = document.getElementById('logout-button');
if (logoutButton) {
logoutButton.addEventListener('click', function(e) {
e.preventDefault();
handleLogout();
});
}
// Additional JavaScript functionality can be added here
}); |