I want the ids of the draggable divs to show up as a comma separated list in the alert button if they were dropped into the droppable_box. Instead there is an alert for each dragged div one after the other instead of as a list. <script type="text/javascript"> $(document).ready(function(){ $( "#draggable1" ).draggable({ grid: [ 20,20 ] }); $( "#draggable2" ).draggable({ grid: [ 20,20 ] }); $( "#draggable3" ).draggable({ grid: [ 20,20 ] }); $( "#droppable_box" ).droppable({ drop: function( event, ui ) { var currentId = $(ui.draggable).attr('id'); var stuff = []; $.each($(ui.draggable), function(i,e) { stuff.push(e.id); }); var energy = stuff.join(", "); var data = "X-Requested-With=XMLHttpRequest"; $('#myId').click(function(){ $.post ( "process.php", data, function(data) { alert(energy); }, 'html' ); }); } }); }); </script> In the html there are 3 draggable divs <div id="draggable1" class="draggable_meal"></div> <div id="draggable2" class="draggable_meal"></div> <div id="draggable3" class="draggable_meal"></div>
I changed the jquery a little and published it here: http://maureenmoore.com/momp_112412/112412.html You can look at the view source. Thanks.
In process.php it gives me 1 to 3 arrays depending on how many divs I dragged. I want to push the $_REQUEST object into an array using foreach ($_REQUEST as $key => $value) { array_push($stack,$value); } print_r($stack); Code (markup): but it gives me 1 to 3 arrays each with the key of zero. How do I get one array out of for example 3 dragged divs?