Check for AJAX Request


/ Published in: PHP
Save to your folder(s)

Determines whether or not the page has been requested directly, or through AJAX. This can allow for combining a page and related AJAX responses within the same script.


Copy this code and paste it in your HTML
  1. function isAjaxRequest() {
  2. return (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
  3. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.