Ajax, tables and parameters - problem


This problem is very strange. I’ve included a very simple controller and
a very simple view that you can drop into any rails environment to test
this problem out.

When I submit a form, and the form is inside a table (say a row in a
table) then the parameters sent on the form submission are different
than if the form is not in a table.

When I run a simple test and I submit a form created with a
“form_remote_tag” method and this form is inside a table,
@params.inspect gives the following:

{“action”=>“ajax_submit”, “controller”=>“ajax_problem”}

Most notable here is that there are no parameters from the form sent in.
The exact same form created outside of a table generates the following:

{“commit”=>“Submit (no table)”, “action”=>“ajax_submit”,
“some_param”=>“a value I typed in”, “controller”=>“ajax_problem”,

Vastly different results. The exact controller and view that I used to
obtain these results are included below. Just cut-and-paste the
controller into app/controllers/ajax_problem_controller.rb and put the
view in app/views/ajax_problem/index.rhtml, then test it out. If anyone
can explain to me what I’m doing wrong and how to fix it, it would be
most appreciated.

******** Sample code ************************
** Here is a very simple controller:

class AjaxProblemController < ApplicationController
layout nil

def index

def ajax_submit
render_text @params.inspect

** Here is a very simple view to show the problem:

Ajax Problem <%= javascript_include_tag "prototype" %>
<%= form_remote_tag(:update => "to_update", :url => { :action => :ajax_submit } ) %> <%= end_form_tag %>
<%= text_field_tag 'some_param' %> <%= submit_tag "Submit (with a table)" %>
 Now outside of a table <br/>
 <%= form_remote_tag(:update => "to_update",
                    :url => { :action => :ajax_submit }
                    ) %>
     <%= text_field_tag 'some_param' %>
     <%= submit_tag "Submit (no table)" %>
 <%= end_form_tag %>


For got to include:
Rails 0.14.3
Ruby 1.8.2



I just did the test, with your exact code and got proper results.

{“commit”=>“Submit (with a table)”, “action”=>“ajax_submit”,
“some_param”=>“Michael”, “controller”=>“ajax_problem”, “_”=>""}

{“commit”=>“Submit (no table)”, “action”=>“ajax_submit”,
“some_param”=>“Michael”, “controller”=>“ajax_problem”, “_”=>""}

This is from IE 6.0. Looks like it may be a versioning issue
somewhere…I just wanted to let you know that the code is proper - at
least from my config.



Matthew T. removed_email_address@domain.invalid wrote:
For got to include:
Rails 0.14.3
Ruby 1.8.2

Matthew T. wrote:

@params.inspect gives the following:
obtain these results are included below. Just cut-and-paste the

Now outside of a table


Form inside Table is not valid HTML.
The Ajax call is based on some javascript code collecting the values of
When the form is inside the table, that code is unable to find any
of the form. (most likely because you placed those parameters like

<%=text_field 'obj','param' %>) So instead of:
and it would work fine



That’s good to know, thank you. I’ll try to borrow someone’s Windows
machine and test. I was using Firefox 1.0.7. Browser issues? Anyone else
out there able to get the crazy results I was getting?


Thank you, that was it. I would have thought that you could make just
one row of a table into a form (as I did) but I guess this is not valid
html, as you said.

I can now confirm what an earlier poster said, that IE 6 does do what I
expect. IE 6 supporting non-standard html? I’m shocked.


IE has always been a pain in the ass for web developers, so I am shocked
that you are shocked :wink: