Reputation: 4959
I'm trying to update a chart after I receive success from an ajax call, but I'm getting this error: TypeError: undefined is not an object (evaluating 'chart.yAxis')
. I'm pretty sure I'm calling the update method correctly. Any ideas? Is the scope of chart affected? it is defined when I check it.
var chart = .... chart ....
$('button#glucose_goals').click(function() {
$.ajax({
url:'glucose/goals',
type: 'POST',
data: $('form#glucose_boundary_form').serialize(),
success: function(data) {
chart.yAxis[0].update({ plotBands: [] });
chart.redraw();
}
});
});
Upvotes: 0
Views: 1455
Reputation: 4769
You trimmed few lines of your code. here is a working fiddle
$('#update1').click(function () {
chart.yAxis[0].update({
plotBands: [{
color: '#FCFFC5',
from: 144,
to: 176,
id: 'plotband-1'
}]
});
});
Upvotes: 1