Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

jquery serialize a collection of tables

Posted on 2016-09-24
3
40 Views
Last Modified: 2016-09-24
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
Comment
Question by:maxdbase
  • 2
3 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 41814132
do a right click on this closest div and paste here this collection of table.
0
 
LVL 22

Expert Comment

by:Kim Walker
ID: 41814311
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
 
LVL 22

Accepted Solution

by:
Kim Walker earned 500 total points
ID: 41814314
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

DOM Attributes and Properties treatment with jQuery 1.6 by Ivo Stoykov jQuery (http://jquery.com/) 1.6 introduces .prop() (http://api.jquery.com/prop/) and .removeProp() (http://api.jquery.com/removeProp/) methods which allow modifying or removi…
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question