Logout with jquery

I was googling for logout with ajax or jquery and found this: http://stackoverflow.com/questions/15506476/run-php-onclick-session-destroy
In this example, there is still a logout.php file. is it possible to have just a logout() function instead of a seprate script? If yes, how can I do this?
calling that logout.php with ajax sounds pretty nonsense to me. why not simply link to logout.php and there add a redirection after session destroy instead of ajax? with ajax I prefer to have just a logout function. is it possible? please advice.