To check Ajax Request in PHP, we will verify the value of HTTP_X_REQUESTED_WITH server header , if has been set, if there is a response, the result is”TRUE” otherwise “FALSE” that means it will returns a boolean response.

This simple php function return true, if request to server is AJAX request.

function is_ajax() {
	return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'));
}