How are XHR requests made when also a post?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How are XHR requests made when also a post?

S Ahmed
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!

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAG2rwuONtt48xRs524uCZ0F8YqL-tgpa-nO8f_%3DWeO_%3DE-UWXg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How are XHR requests made when also a post?

Norbert Melzer-2
(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 ;)

S Ahmed <[hidden email]> schrieb am Mi., 16. Aug. 2017 um 04:34 Uhr:
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!

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAG2rwuONtt48xRs524uCZ0F8YqL-tgpa-nO8f_%3DWeO_%3DE-UWXg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CA%2BbCVssauo1C%2B%2B9b9JjRd55kS9Xs%2B6JFDshrffnPqTAjcUhBUw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How are XHR requests made when also a post?

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

On Wed, Aug 16, 2017 at 7:45 AM, Norbert Melzer <[hidden email]> wrote:
(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 ;)

S Ahmed <[hidden email]> schrieb am Mi., 16. Aug. 2017 um 04:34 Uhr:
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!

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAG2rwuONtt48xRs524uCZ0F8YqL-tgpa-nO8f_%3DWeO_%3DE-UWXg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CA%2BbCVssauo1C%2B%2B9b9JjRd55kS9Xs%2B6JFDshrffnPqTAjcUhBUw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAG2rwuOWb77%2BzY0OrNUVJCD_Fgt%3DzZQAd_xuX0VMXERXMNJt9w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How are XHR requests made when also a post?

Hassan Schroeder-2
On Wed, Aug 16, 2017 at 5:25 AM, S Ahmed <[hidden email]> wrote:
> 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 😀

--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yCtx%2BvukrhGL8pRF5HwXi4mhDU%2BWLMhpjquSiFoRyOo%3Dg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.