Page 1 of 1

jQuery serialization of divs [SOLVED]

Posted: Mon Sep 17, 2007 4:43 pm
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.

Posted: Mon Sep 17, 2007 6:45 pm
by s.dot
OK. I suppose I can't serialize div elements. Only form elements. =/

Posted: Mon Sep 17, 2007 6:52 pm
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

Posted: Tue Sep 18, 2007 2:42 am
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!