Skip to content

Instantly share code, notes, and snippets.

@romaimperator
Created June 25, 2013 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save romaimperator/5863143 to your computer and use it in GitHub Desktop.
Save romaimperator/5863143 to your computer and use it in GitHub Desktop.
# Returns true if the "X-Requested-With" header contains "XMLHttpRequest"
# (case-insensitive). All major JavaScript libraries send this header with
# every Ajax request.
def xml_http_request?
@env['HTTP_X_REQUESTED_WITH'] =~ /XMLHttpRequest/i
end
alias :xhr? :xml_http_request?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment