How are XHR requests made when also a post?

In rails 2.2 there was checks in the code like:

if request.post?

if request.xhr?

end

end

If a HTTP POST is made, how would also be considered a XHR request?

Thanks!

(new XMLHttpRequest).open(‘POST’, ‘foo.xml’, ‘data’) via JavaScript should do a POST request. At least according to wikipedia. But Rails 2.2 is quite old, you should prepare to rewrite :wink:

I know about the post request. Just ensure when it is considered a post.xhr? request.

From rack 2.0.3 lib/rack/request.rb:

def xhr?     get_header("HTTP_X_REQUESTED_WITH") == "XMLHttpRequest" end

This is from Rails 5.1.2, btw. You can find the equivalent somewhere in the 2.2 source, I imagine :grinning: