How to handle redirection in an Ajax based application
- by nimo
hi all,
I'm developing a Ajax based php application. As anybody knows, I'm checking whether user is logged in every php file as the first statement. And there are two ways that I should response in an event of logging failure,
server redirect to the login page using header(url).
CASE: If user directly enter a particular URL
passing url in Ajax response asking client side page redirection or notification
CASE: If user trying to perform some action through a Ajax request
So my question is how can identify whether request coming from client side is a Ajax call or not ? If I know that I can handle my response accordingly.
OR Is there a better way of handling above scenario ?
Thank You