javascript - JSON to jQuery charts -


i have pdo script echos json sql table.

i trying display json info in jquery chart no success.

i error in chrome debugger refers first jquery code line below (var json).

function reference:

    uncaught syntaxerror: unexpected identifier angular.js:11598 referenceerror: index not defined     @ eval (eval @ <anonymous> (http://localhost/assets/global/plugins/jquery.min.js:2:2622), <anonymous>:2:2)     @ eval (native)     @ http://localhost/assets/global/plugins/jquery.min.js:2:2622     @ function.m.extend.globaleval (http://localhost/assets/global/plugins/jquery.min.js:2:2633)     @ m.fn.extend.dommanip (http://localhost/assets/global/plugins/jquery.min.js:3:23159)     @ m.fn.extend.append (http://localhost/assets/global/plugins/jquery.min.js:3:20620)     @ null.<anonymous> (http://localhost/assets/global/plugins/jquery.min.js:3:22151)     @ m.access (http://localhost/assets/global/plugins/jquery.min.js:3:3399)     @ m.fn.extend.html (http://localhost/assets/global/plugins/jquery.min.js:3:21736)     @ compile (http://localhost/assets/global/plugins/angularjs/plugins/angular-ui-router.min.js:7:21866) <div ui-view="" class="fade-in-up ng-scope">(anonymous function) @ angular.js:11598$get @ angular.js:8548$ @ angular.js:8219v @ angular.js:7726g @ angular.js:7075(anonymous function) @ angular.js:6954k @ angular-ui-router.min.js:7(anonymous function) @ angular-ui-router.min.js:7$get.l.$broadcast @ angular.js:14707x.transitionto.x.transition.i.then.x.transition.x.transition @ angular-ui-router.min.js:7(anonymous function) @ angular.js:13175$get.l.$eval @ angular.js:14388$get.l.$digest @ angular.js:14204(anonymous function) @ angular.js:14427e @ angular.js:4902(anonymous function) @ angular.js:5282 

php:

<?php   $dbh = new pdo("mysql:host=localhost;dbname=test", "root", ""); $statement=$dbh->prepare("select * pdotable"); $statement->execute(); $results=$statement->fetchall(pdo::fetch_assoc); $json=json_encode($results, json_pretty_print);  header('content-type: application/json');  echo $json; ?> 

jquery:

var json = (function () {                 var json = null;                 $.ajax({                     'async': false,                     'global': false,                     'url': 'pdo/phpinfo.php',                     'datatype': "json",                     'success': function (data) {                         json = data;                     }                 });                 return json;             });          initcharts: function() {              if (morris.eventemitter) {                 // use morris.area instead of morris.line                 dashboardmainchart = morris.area({                     element: 'sales_statistics',                     padding: 0,                     behavelikeline: false,                     gridenabled: false,                     gridlinecolor: false,                     axes: false,                     fillopacity: 1,                     data:json,                 linecolors: ['#399a8c', '#92e9dc'],                 xkey: 'period',                 ykeys: ['sales', 'profit'],                 labels: ['sales', 'profit'],                 pointsize: 0,                 linewidth: 0,                 hidehover: 'auto',                 resize: true             });          }     }, 

what doing wrong?


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -