Detecting an Ajax Request with PHP

Here’s a quick piece of code that i find useful to check if a request that comes to a PHP page was made via an Ajax call or a simple form post. This method uses the $_SERVER[‘HTTP_X_REQUESTED_WITH’] request to determine if data was sent to a specific page using an xmlhttprequest. It’s worth bearing in …