This is my cart.php file. array i encoded to json and return to ajax function:
$data = array();
$data['total'] = '10000';
$data['quantity'] = '10';
echo json_encode($data);
This my index.php file. I create function ajax to return my array value in cart.php but the value is undefined:
function view()
{
$.ajax({
url: 'cart.php',
type:'POST',
data:{action:'total'},
datatype:'json',
success: function (data) {
alert(data.total);
}
});
}