I use the jQuery UI sortable plugin and I don’t succeed to send the “order” var (an array) with AJAX. After the ajax sending “order” is not an array anymore. I would like to have a solution only for the ajax sending.
$("#list-cat").sortable({
placeholder: 'highlight',
update: function() {
var order = $('#list-cat').sortable('serialize');
$.ajax({
dataType: 'json',
type: "POST",
url: "my_url.php",
data: { action: "edit_cat_order", id_member: "<?php echo $id_member; ?>", id_page: "<?php echo $id_page; ?>", order: order },
success: function(data){
if (data.a == true){
$.colorbox({ html: data.b });
}
},
error:function (xhr, ajaxOptions, thrownError){
alert(xhr.responseText);
}
});
}
});
In “my_url.php”, a foreach loop doesn’t recognize $_POST[‘order’] as an array : “Invalid argument supplied for foreach() …”. I think the problem is in the “data” line because $_POST[‘order’] is an array when I use :
$.post("my_url.php", order);
you can try
EDIT
you can use
$.makeArray