jQuery serialization of divs [SOLVED]

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

jQuery serialization of divs [SOLVED]

Post by s.dot »

Code: Select all

<div class="cont">
    <div class="sortableitem" id="friendslist_97333"> ... </div>
    <div class="sortableitem" id="friendslist_100507"> ... </div>
    <div class="sortableitem" id="friendslist_96977"> ... </div>
</div>
This is using the sortable javascript, so the inner divs may be in any order. I need to serialize them so I can pass them to a php script.

I've tried....

Code: Select all

$('div.cont').serialize();

/* and */

$('div.cont').serializeArray();
Both of them come up blank. I need it so I can get a string like &friendslist[]=97333&friendslist[]=100507... etc.
Last edited by s.dot on Mon Sep 17, 2007 6:52 pm, edited 1 time in total.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

OK. I suppose I can't serialize div elements. Only form elements. =/
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Okay, I finally got it working.
Wowza.

I suggest for your first project using jquery or ajax or advanced javascript to NOT do draggable/droppable sortable elements using ajax to save a serialized array to a database. :D
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

That is one of the tougher ones to implement - I remember being a tad confused myself at first. How very un-jQuery-like!

Glad you got it working though!
Post Reply