# Ajax, tables and parameters - problem

**URL:** <https://www.ruby-forum.com/t/ajax-tables-and-parameters-problem/47800>\
**Category:** Rails\
**Created:** [November 14, 2005, 12:26am UTC](https://www.ruby-forum.com/t/ajax-tables-and-parameters-problem/47800 "2005-11-14T00:26:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mithill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9dc877/32.png) [@mithill](https://www.ruby-forum.com/u/mithill)\
**Post date:** [November 14, 2005, 12:26am UTC](https://www.ruby-forum.com/t/ajax-tables-and-parameters-problem/47800/1 "2005-11-14T00:26:35Z")

</div>

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  
end

def ajax\_submit  
render\_text @params.inspect  
end  
end

\*\* 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/>
 <br/>
 <%= form_remote_tag(:update => "to_update",
                    :url => { :action => :ajax_submit }
                    ) %>
     <%= text_field_tag 'some_param' %>
     <%= submit_tag "Submit (no table)" %>
 <%= end_form_tag %>

```

---

<div class="post-metadata">

**Author:** ![mithill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9dc877/32.png) [@mithill](https://www.ruby-forum.com/u/mithill)\
**Post date:** [November 14, 2005, 1:14am UTC](https://www.ruby-forum.com/t/ajax-tables-and-parameters-problem/47800/2 "2005-11-14T01:14:38Z")

</div>

For got to include:  
Rails 0.14.3  
Ruby 1.8.2  
Gentoo

---

<div class="post-metadata">

**Author:** ![mithill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9dc877/32.png) [@mithill](https://www.ruby-forum.com/u/mithill)\
**Post date:** [November 14, 2005, 1:29am UTC](https://www.ruby-forum.com/t/ajax-tables-and-parameters-problem/47800/3 "2005-11-14T01:29:41Z")

</div>

Matt,

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.

Regards,

Michael

Matthew T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:  
For got to include:  
Rails 0.14.3  
Ruby 1.8.2  
Gentoo

Matthew T. wrote:

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

> Now outside of a table

>

---

<div class="post-metadata">

**Author:** ![mithill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9dc877/32.png) [@mithill](https://www.ruby-forum.com/u/mithill)\
**Post date:** [November 14, 2005, 1:35am UTC](https://www.ruby-forum.com/t/ajax-tables-and-parameters-problem/47800/4 "2005-11-14T01:35:41Z")

</div>

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

\<%=text\_field 'obj','param' %\>) So instead of:

| |

use

| |

and it would work fine

Bogdan

---

<div class="post-metadata">

**Author:** ![mithill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9dc877/32.png) [@mithill](https://www.ruby-forum.com/u/mithill)\
**Post date:** [November 14, 2005, 5:45am UTC](https://www.ruby-forum.com/t/ajax-tables-and-parameters-problem/47800/5 "2005-11-14T05:45:12Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mithill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9dc877/32.png) [@mithill](https://www.ruby-forum.com/u/mithill)\
**Post date:** [November 14, 2005, 6:00am UTC](https://www.ruby-forum.com/t/ajax-tables-and-parameters-problem/47800/6 "2005-11-14T06:00:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mithill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9dc877/32.png) [@mithill](https://www.ruby-forum.com/u/mithill)\
**Post date:** [November 14, 2005, 10:26am UTC](https://www.ruby-forum.com/t/ajax-tables-and-parameters-problem/47800/7 "2005-11-14T10:26:57Z")

</div>

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