I know this question has been asked before many times but none of them helped me. I am trying to pass an array of arrays(which may or may not have arrays in themselves) through data using $.ajax(). The response received from the server should be the same as data sent (acc to the code in php) but it sends blank object. Please help me knowing the correct syntax of passing such an array.
val_pass is an array of arrays and #display_message is paragraph to append on. Here goes my code:
$.ajax({
type: 'POST',
url: 'http://someurl.com/',
// data: JSON.stringify(val_pass),
// data: JSON.stringify({paramName: val_pass}),
// data: {'myArray': val_pass},
// data: $.toJSON(val_pass),
data: {val_pass: val_pass},
// data: $.serialize(val_pass),
success: function(response){
console.log(response);
$('#display_message').append('Data successfully passed');
},
error: function(xhr, status, errorThrown){
console.log(xhr+status+errorThrown);
alert("Sorry");
},
});
PS: commented lines are various ways i tried to pass an array. I am new to ajax please ignore my noobness.