How to check if a Request was made via AJAX in PHP

4 sec read

// Check for Ajax Request  
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') {
    //Do stuff here
}

Last Updated On March 22, 2018

Leave a Reply

avatar
  Subscribe  
Notify of