Solved

jquery serialize a collection of tables

Posted on 2016-09-24
3
29 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JS Plugin Chaining 2 32
popup load of page and setting up of session 8 22
Error in script 11 45
bootstrap footer centering and columns alignement 3 2
What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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…

914 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now