/ Published in: PHP
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.
Expand |
Embed | Plain Text
function isAjaxRequest() { return (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'); }
Comments
Subscribe to comments
You need to login to post a comment.

Forgot to mention this snippet was inspired by David Walsh's post here: http://davidwalsh.name/detect-ajax
Forgot to mention this snippet was inspired by David Walsh's post here: http://davidwalsh.name/detect-ajax