Check AJAX requests from PHP

This post was written by Mahi-Bhat on January 1, 2013
Posted Under: PHP

Here is a simple PHP function to check the AJAX requests .

// Function to check AJAX request
function is_ajax_request() {
$ajax_request = (!empty($_SERVER[‘HTTP_X_REQUESTED_WITH’]) && strtolower($_SERVER[‘HTTP_X_REQUESTED_WITH’]) == ‘xmlhttprequest’) ? true : false);

return $ajax_request;

Add a Comment

required, use real name
required, will not be published
optional, your blog address