I now this question has been asked before but I am trying to work this out since this morning and I can't get it right.
I have a global variable named items
I have a .ajax request that I need to send the contents of the items array
Items is like this
items = new Array();
for (var i = 0; i < 10; i++)
{
//just populating the list
var item = [];
item['some_stuff'] = 'string';
item['some_int'] = 373;
items.push(item);
}
//here is the request
if (items.length > 0)
{
$.ajax({
type : "POST",
url : "/grad1/adaugaComanda.php",
data : { "stuff" : items},
success : function (data){
alert(data);
// window.location = '/dashboard.php?categ=5&sel=1';
}
});
}
//
The request is executed but data is not sent. I tried to use JSON.stringify on the array but it returns empty ([[]]).
Any ideas what I am doing wrong ?