View our GitHub

Please visit sails-docs on GitHub to view documentation on your mobile device.

Edit Page

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

req.xhr;

Example

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

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.

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails-docs repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.

Reference

We wrote a book!

Get early access to the book
with promotion code: mcneildoc

Get the Book