Link_to_remote and browser compatibility

link_to_remote generates the javascript: new Ajax.Updater(…). Have I
missed something or doesn’t this handle browsers with javascript support
but without XHR support?

What I’d like to do is:

  1. If the browser supports XHR, use XHR
  2. If the browser supports javascript (and perhaps even if the XHR
    request fails) do a POST via javascript
  3. If the browser doesn’t support javascript use POST via a standard
    form

Is that possible?

Thanks in advance,

Jonas Bengtsson

did you include this in your header?

<%= javascript_include_tag ‘prototype’, ‘scriptaculous’ %>

as well as have those files in your javascripts folder found in the
public directory?

there is also a url_for attribute that you can add to your
link_to_remote that will do a post if the browser does not have
javascript turned on or does not support it.

Andrew

Thanks for your answer Andrew,

Andrew F. wrote:

did you include this in your header?

<%= javascript_include_tag ‘prototype’, ‘scriptaculous’ %>

as well as have those files in your javascripts folder found in the
public directory?

Yes. link_to_remote works when I use a browser with XHR support so
everything is set up correctly.

there is also a url_for attribute that you can add to your
link_to_remote that will do a post if the browser does not have
javascript turned on or does not support it.

Do you mean options[‘url’]? Won’t it just do a GET on that url if
javascript is turned off (I want a POST)? And that still don’t address
browsers without XHR support.

/Jonas