I have a form that includes several input text fields and a list that's sortable (se code below). The function below retrieves the new positions that's saved to an array (order). However, what I want is to include the array in the form so that when the user is finished with the sorting, has filled in the text fields and submits the form this array will be apart of the form.
So, how could I get this array into the form with AJAX?
$('#listElements').sortable({
//revert: true,
update: function(event, ui) {
var order = [];
$('.listObject li').each(function (e) {
order.push($(this).attr('id'));
});
$.ajax({
url: "/index.php?type=list&action=showList&listId=1",
type: "post",
data: {
order_data: order
}
}).success(function (data) {
console.log(data);
});
}
});
NOTE: To make it clear, I want to get the array into the form.