Wednesday 16 January 2013

How to know request is ajax or other in php


How to know whether the request is an ajax request or normal request in PHP? 

We can know it through following code:

$ajax false;

if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
 $ajax = true;
}
echo $ajax;

No comments:

Post a Comment