Uncaught SyntaxError: Unexpected token < in CodeIgniter

Viewed 3592

I am currently working on CodeIgniter charts, but am getting an error like:

Uncaught SyntaxError: Unexpected token <

And charts are not loading showing blank.

var data_course_stats = google.visualization.arrayToDataTable([
          ['Course', 'Time spent',{ role: 'style' }],
           <?php 
           $i=0;
           foreach ($timespent_stats as $course) { $course = (object)$course;
           $color_val = 'green';
            if(count($i<count($timespent_stats)))
              $color_val = $colors[$i++];
            ?>
         ['<?php echo $course->title;?>', <?php echo $course->spent_seconds/60;?>,'<?php echo $color_val; ?>'],
         <?php } ?>
        ]);

        var options_course_stats = {
          title: 'Course Wise Spent Time in Minutes',
          curveType: 'function',
           height: 400,
             bar: {groupWidth: "50%"},
          legend: { position: "none" },
};
3 Answers

If anyone get this problem again, check if your base_url is correct in config/config.php

Related