• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 70
  • Last Modified:

jquery serialize a collection of tables

how can I get the individual tables in this each loop to display .serialize()

Screenshot:  http://www.screencast.com/t/w59pGCrThT

Currently the .serialize is blank yet the table has several inputs all with name and id

            var serializedcontent = ""
            $(target).closest('div').find('table').each(function(){
                  if($(this).attr("id"))
                  {
                        if($(this).attr("id").indexOf("BT20") > -1)
                        {
                        alert($(this).attr("id") + "~" + $('table#' + $(this).attr("id")).serialize())      
                        serializedcontent += $(this).attr("id") + "~" + $(this).serialize() + "^"
                        }
                  }
                  
            })
0
maxdbase
Asked:
maxdbase
  • 2
1 Solution
 
leakim971PluritechnicianCommented:
do a right click on this closest div and paste here this collection of table.
0
 
Kim WalkerWeb Programmer/TechnicianCommented:
The total absence of semi-colons in your code is suspect. Is anything happening at all? Are you getting an alert? Does the alert contain the id and tilde but not the serialized id?

I am unfamiliar with the use of serialize on an attribute. The serialize function is typically executed on a form element. In fact, the documentation states
For a form element's value to be included in the serialized string, the element must have a name attribute.
But in your case, you are serializing the value of the id attribute of the target element. What do you expect the serialize function to return in this case?
0
 
Kim WalkerWeb Programmer/TechnicianCommented:
Wait. Now I see that your are appending the value of the id attribute to the string table#. I believe you are intending to target the element with the target id that is a descendant of any table. If that is the case, you need to insert a space between table and #.
$('table #' + $(this).attr("id")).serialize()

Open in new window

However, since id values are required to be unique, the table ancestor selector is unnecessary.
$('#' + $(this).attr("id")).serialize()

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now