I have some pages set up so that they respond only to ajax requests. The thing is that how can I set it up so that if someone tries to send the requests via a browser window i.e by typing them out – they don’t run and that they run only when an ajax call is made. The pages are in php here
Share
There’s no reliabale way to distinguish an AJAX request from a normal request. Some libraries such as jQuery will append an additional
X-Requested-With: XMLHttpRequestHTTP header to the request, but others might not. You could forge an AJAX request using the low level objects provided by the browser that looks exactly the same as a normal request so don’t rely much.