Redirecting to Login Screen when clicking a button

Hi all,
i wrote a panel widget with (simple) ajax for testing reasons. you can click a button and the content of a specific html element changes (planning a specific database widget). if the button is clicked the referenced html element changes, but if you click on options or somewhere else in the panel then you get directed to the login screen. is there a workaround or has somebody an idea of how to fix this?
thanks in advance!
snafu

It might be that your AJAX code invalidates the CSRF token. The next request will then be invalid and the user is logged out. Could you please post your code?