Hello , I have this code :

<?php
    include("funciones.php");
    $link = conectar();
    $consulta = "SELECT Mes, SUM(CantidadAnyoAnterior) AS CantidadAnterior, 
SUM(CantidadObjetivo) AS CantidadObjetivo, SUM(CantidadReal) AS 
CantidadReal FROM objetivo";
    $consulta .= " WHERE Anyo = 2012 GROUP BY Mes ORDER BY Mes";
    $result = mysqli_query($link, $consulta);
    if (mysqli_num_rows($result)>0) {    
        $datos = array();
        while ($filaregistro = mysqli_fetch_array($result)) {
            $datos[] = array ('Mes:' => $filaregistro['Mes'], 'Cantidad:' 
=> $filaregistro['CantidadAnterior']);
        }
    }
    mysqli_close($link);
    echo json_encode($datos);
?>


and another file with :



<script type="text/javascript">

function callback_error(XMLHttpRequest, textStatus, errorThrown)
{
    alert(errorThrown);
}

function inicia() {

    var datos = $.ajax({
            url: 'acceso_1.php',
            type: 'POST',
            dataType: 'json',
        error: callback_error,
            async: false
        }).responseText;

        datos = JSON.parse(datos);
    
        google.load("visualization", "1", {packages:["corechart"]});
          google.setOnLoadCallback(dibujarGrafico);
      
          function dibujarGrafico() {
            var data = google.visualization.arrayToDataTable(datos);

            var options = {
              title: 'VENTAS DEL PRIMER BIMESTRE',
              hAxis: {title: 'MESES', titleTextStyle: {color: 'green'}},
              vAxis: {title: 'MILES DE PESOS', titleTextStyle: {color: 
'#FF0000'}},
              backgroundColor:'#ffffcc',
              legend:{position: 'bottom', textStyle: {color: 'blue', 
fontSize: 13}},
              width:900,
            height:500
            };

            var grafico = new 
google.visualization.ColumnChart(document.getElementById('grafica'));
            grafico.draw(data, options);
          }

}

When Ajax call the file .php display this error message and the grafic is 
not display :

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the 
JSON data


Any idea for this question ??????
Thanks.


-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to