fellybikush's picture
Upload 99 files
0dff816 verified
raw
history blame
883 Bytes
// 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
});