Reputation: 13
i am getting this response after ajax post
Array
(
[curve] => Array
(
[0] => stdClass Object
(
[date1] => 2018
[total1] => 0
)
[1] => stdClass Object
(
[date1] => 2018
[total1] => 200
)
[2] => stdClass Object
(
[date1] => 2018
[total1] => 0
)
[3] => stdClass Object
(
[date1] => 2018
[total1] => 0
)
[4] => stdClass Object
(
[date1] => 2018
[total1] => 0
)
)
)
and my post request is as below:
$.post("<?=base_url();?>app/total_meter_feeder_r_curve", { divid: divid,id:id}, function(result)
{
alert(result);
$('.basefp').hide();
// chart.series[0].setData([first,second]);
});
i want to retrieve value on ajax success of "total1" only . how could i achieve this. on alerting result i am getting the above array.
Upvotes: 0
Views: 371
Reputation: 1038
So basically you have got result
in response of ajax success ,
result variable is array of objects. Hence Now you have to travel into this array, so the total1
is a variable in one of object in array of result['curve'].
If you try below snippet your problem should get resolve:
jQuery.each(result['curve'], function(index, value) {
alert(value.total1);
});
Upvotes: 4