i have a functions.php page with a dologout function
function doLogout() {
if (isset($_SESSION['user_id'])) {
unset($_SESSION['user_id']);
unset($_SESSION['location']);
}
header('Location: index.php');
exit;
}
and a home.php page with a logout button with onclick method to logout function which is as follow
function logout()
{
$.ajax({
url: "functions.php",
type: "POST",
dataType: "dataString",
data: {func:"doLogout"},
}).done(function() {
alert( "LoggedOut Succesfully");
});
}
}
}
But this function is not working i tried looking at other answers but none of them actually answers how to call a function using ajax. Can anyone please help me? Thanks in advance