req.xhr

A flag indicating whether the current request (req) appears to be an AJAX request (i.e. it was issued with its “X-Requested-With” header set to “XMLHttpRequest”.)

Usage

  1. req.xhr;

Example

  1. if (req.xhr) {
  2. // Yup, it's AJAX alright.
  3. }

Notes

  • Whenever possible, you should prefer the req.wantsJSON flag. Avoid writing custom content-negotiation negotiation logic into your app - it makes your code more brittle and more verbose.