On Thu, Jan 5, 2012 at 5:26 PM, Craig White <craig.wh...@ttiltd.com> wrote:
>
> On Jan 5, 2012, at 3:57 PM, Bill Walton wrote:
>>
>> Then my best advice would be to double check the accepts header using
>> Live Http Headers.  You may need to do some explicit setup prior to
>> the post.
> ----
> wish I understood what you are trying to tell me here

My apologies.  Not sure which part of the three above I should
address, so here's all three.

1) Rails decides which respond_to block to use based on the request's
Accept header.  Here's a link that should help on that front.
http://www.gethifi.com/blog/browser-rest-http-accept-headers

2) Live HTTP is a plugin for Firefox that shows you the headers for
each request-response cycle.  I've pasted in the first frame you'll
get visiting the link above below.  It's got 2 sections.  The first
shows the headers sent on the request.  The second shows the headers
sent on the response. The Accept header content is on the 4th line of
the request section.  In this case, the client is telling the server
that its first preference is for html and you can see from 2nd line in
the response section that that is what the server sends back.


GET /blog/browser-rest-http-accept-headers HTTP/1.1

Host: www.gethifi.com

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.24)
Gecko/20111107 Ubuntu/10.04 (lucid) Firefox/3.6.24

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Accept-Language: en-us,en;q=0.5

Accept-Encoding: gzip,deflate

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

Keep-Alive: 115

Connection: keep-alive

Referer: 
http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&ved=0CDwQFjAC&url=http%3A%2F%2Fwww.gethifi.com%2Fblog%2Fbrowser-rest-http-accept-headers&ei=9z4GT6y7K4X-sQKd25SRCg&usg=AFQjCNFXKdbpcUNstr0O0jkYtWvhb4EjYQ&sig2=Ycrt2dIClGHE4IldZUeJzw

Cookie: __utma=1.1465277256.1325809449.1325809449.1325809449.1;
__utmb=1.1.10.1325809449; __utmc=1;
__utmz=1.1325809449.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided);
__lo__roomid=2489

Cache-Control: max-age=0



HTTP/1.1 200 OK

Content-Type: text/html

Expires: Thu, 05 Jan 12 19:20:20 -0500

Cache-Control: max-age=60

Vary: Accept-Encoding

Content-Encoding: gzip

Content-Length: 21416

Accept-Ranges: bytes

Date: Fri, 06 Jan 2012 00:25:13 GMT

Connection: keep-alive


3) If what you see from looking at what's produced in Live HTTP by
your post is that the request's Accept header is not requesting
javascript (text/script iirc) then the problem is explained.  The
'fix' is to set the request's Accept header.  I did a quick google on
'jquery ajax set header' and got good results.  This one looked like a
good place to start.
http://snipplr.com/view/9869/

This one might be a good look if the one above doesn't get you the
results you need.
http://stackoverflow.com/questions/1145588/cannot-properly-set-the-accept-http-header-with-jquery

HTH,
Bill

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to