request.xhr? is only for Prototype? 3
I just found this lovely tid-bit of information in the ActionController::AbstractRequest class…
# Returns true if the request's "X-Requested-With" header contains
# "XMLHttpRequest". (The Prototype Javascript library sends this header with
# every Ajax request.)
def xml_http_request?
!(@env['HTTP_X_REQUESTED_WITH'] !~ /XMLHttpRequest/i)
end
alias xhr? :xml_http_request?Mental note for later: Make sure to set this header when using jQuery in future projects…. Not sure if jQuery does this already (probably not).
Comments
-
jQuery sets it, too.
-
I was going to say that I follow this: http://ozmm.org/posts/jquery_and_respond_to.html But it looks like Jason already answered you question :-)
-
HA HA! Now you're wrong three times!
