Skip to content

Instantly share code, notes, and snippets.

@Bujhm
Created March 28, 2018 23:59
Show Gist options
  • Save Bujhm/65ec8f0ba09c7566c4b6c290d376bf9d to your computer and use it in GitHub Desktop.
Save Bujhm/65ec8f0ba09c7566c4b6c290d376bf9d to your computer and use it in GitHub Desktop.
detect ajax
<?php // got from here https://www.sanwebe.com/2011/02/how-to-detect-ajax-request-using-php
//detect ajax
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
die('Request must come from Ajax!');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment