How to Check Ajax Request with PHP

In this tutorial, you will go through how to check ajax request with php scripts. This trick will be very useful and handy when you want the same request to behave differently for AJAX request and normal.

In PHP, The $_SERVER['HTTP_X_REQUESTED_WITH'] variable is one strong sign that an AJAX request has been made from browser. header is sent by all recent browsers that support AJAX requests.

$is_ajax = false;
&& strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') 
$is_ajax = true;

Hope this is useful for you 🙂

(Visited 11 times, 1 visits today)
Chandra Kumar

Hello World, I am Chandra Kumar from New Delhi, India. I am professionally developer, programmer and blogger. I am the founder of

0 Comment

Leave a Comment

Your email address will not be published. Required fields are marked *