I want to retrieve array for my ajax function using json_encode in Laravel PHP, but the problem is i need to send 2 multidimensional array from my controller so i can do nested loop inside my ajax using those 2 different multidimensional array,
the ajax simple example (this is my wrong version):
function getData() {
jQuery(document).ready(function() {
jQuery.ajax({
url: "test",
type: 'GET',
data: {counter : ctr},
dataType: "json",
success: function(data1,data2) {
$.each(data1.length, function(i, item) {
alert(data1[i].test1);
$.each(data2, function(i, item) {
alert(data2[i].test2);
});
});
},
error: function(data) {
}
});
});
}
sending data php using json_encode code:
$data1 = array
(
array("test1",22,18),
array("wow",15,13));
$data2 = array
(
array("test2",22,18),
array("ish",15,13));
echo json_encode(???);