I’m trying to pass an array like this using jQuery, but the PHP script never receives it and a look through Chrome’s network trace shows that only title is passed.
var items = new Array();
items[0] = new Array();
items[0]['code'] = '1234';
items[0]['checked'] = true;
items[1] = new Array();
items[1]['code'] = '4524';
items[1]['checked'] = false;
This is the code that does the AJAX request:
var sUrl = "<?= base_url(); ?>list/create/";
var serialized = {
title: 'Some Value Here',
items: items
};
$.ajax({
url: sUrl,
type: "POST",
data: serialized,
success: function(data) {
alert(data);
list_id = data;
}
});
The problem seems to be that jQuery can’t serialize it. Is there any way around this? Thanks!
What happens when you create your items object like this:
I think the problem is you’re creating an array with your interior object when you should just be creating a standard object.