Check for AJAX Request in PHP

A simple PHP function to check if the request comes from an AJAX XMLHttpRequest.
Use it if you want your page or script to behave differently when called from AJAX.

The Function:

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

[ad name=”Adsense – text only”]

Leave a comment

Your email address will not be published.