c_pattle Posted February 24, 2011 Share Posted February 24, 2011 I have a global variable called options that I have defined which is an array. var options = { series: [{ type: 'pie', name: 'Title 2 Rating Distribution', data: [] }] }; How do I then insert something into this array from another function? For example I want to perform an ajax request and then copy the returned data into the variable called "data". However if I try to do the follow it says that "options.series.data is undefined". $.ajax({ url: 'ajax/pie_chart_data.php', success: function(point) { options.series.data.push(point); }, }); Thanks for any help. Quote Link to comment https://forums.phpfreaks.com/topic/228744-jquery-help/ Share on other sites More sharing options...
trq Posted February 25, 2011 Share Posted February 25, 2011 options is not an array, it is an object. series is however an array with one element, another object. You would need to use.... options.series[0].data.push(point); Quote Link to comment https://forums.phpfreaks.com/topic/228744-jquery-help/#findComment-1179349 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.