Skip to content

Instantly share code, notes, and snippets.

@kroatoanweb
Last active August 11, 2017 14:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kroatoanweb/13226c93db987286dfaecc184bee01b7 to your computer and use it in GitHub Desktop.
Save kroatoanweb/13226c93db987286dfaecc184bee01b7 to your computer and use it in GitHub Desktop.
Como detectar una petición ajax en PHP plano.
<?php
//Acciones que calculen el contenido
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
//Mostramos el contenido en el formato especifico para las llamadas ajax
//Acabamos con un return o un die para evitar seguir ejecutando el codigo
}
//Mostramos el contenido en el formato normal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment