How do i change this into JSON?

Illelatum

New Member
How can I send multiple values to be picked up like this using JSON?\[code\]foreach($_POST['listItem'] as $key => $values){ list($eventDate, $eventTitle) = $values;}\[/code\]At the moment the values are sent as follows. But this doesn't appear to work properly as it is only sending some of the string. I also can't figure out where/how to send the caltitle value.This is sending me crazy. Any help would be great.\[code\]var txt = $("#listbox"); var caltitle = copiedEventObject.title var dtstart = $.fullCalendar.formatDate(copiedEventObject.start, 'yyyyMMdd'); var txt = $('#listbox'); txt.append("<li class ='listItem'> " + dtstart + "</li>") // remove the element from the "Draggable Events" list $(this).remove(); } }); $('#calendarform').submit(function(e) { var form = $(this); var listItems = $('.listItem'); listItems.each(function(index){ //For each event do this: var listItem = $(this); $("<input type='hidden'/>").val(listItem.text()).appendTo(form).attr('name', 'listItem[' + index + ']'); }); //Get text information from elements });\[/code\]EDIT:(using JSON)\[code\] $('#calendarform').submit(function(e) { var form = $(this); var going_to_be_json = []; list.each(function(i, item) { going_to_be_json.push({ 'id':'test', 'title': 'test' }); }); $('#stuff').val( JSON.stringify(going_to_be_json) ); });\[/code\]
 
Back
Top