Hi Don (or anybody who can help! ;-) )
I''m having exactly the same problem. Did you ever figure this out?
Has anybody gotten respond_to to actually work?
Thanks,
Bill
----- Original Message -----
From: Don Walker
To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
Sent: Monday, May 08, 2006 11:40 PM
Subject: [Rails] AJAX request not setting Accept header
I''m trying to stay DRY and use respond_to as I move to AJAX in my
apps, but I''m getting some mysterious behavior. Here''s a
simple form I''m testing with:
<%= form_remote_tag :url => {:action => ''submit''}
%>
<%= submit_tag ''Go'' %>
<%= end_form_tag %>
When I submit the following HTTP request is sent:
POST /test/submit HTTP/1.1
Host: localhost:3000
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3)
Gecko/20060426 Firefox/1.5.0.3
Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
<snip />
Notice that "text/javascript" appears nowhere in the Accept list!
Because of this absence I would not expect respond_to to correctly catch the
AJAX submission, and it doesn''t. Instead HTML is triggered every time.
respond_to do |wants|
wants.js { render } # Never triggered
wants.html { redirect_to :action => ''WHY?'' } # Always
triggered
end
If I remove the "wants.html" line my RJS template performs the
expected dynamic actions, so I know that Javascript is enabled, but I''m
at a complete loss as to why the Accept headers are not being set... can anyone
point out what I am missing?
Don
------------------------------------------------------------------------------
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---