As a Python developer who is new to JavaScript and AJAX, I am currently working on creating a pie chart that displays database values.
$(document).ready(function () {
google.charts.load('current', { 'packages': ['corechart'] });
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
$.ajax({
url: '/dashboard/document/',
type: 'POST',
dataType: 'json',
data:{
csrfmiddlewaretoken: '{{ csrf_token }}'
},
success: function (response) {
console.log(response.result);
$.each(response.result, function (item) {
console.log(item);
I have fetched my database values using PyMongo, which are stored in console.log(response.result);
. Now, I need to print each value using looping with console.log(item);
. How can I achieve this?