Ajax take data from php problem

In a php file (ajax_chart.php) I have this

        include '../main_includes/connect_db.php';
        $present_day = date("d");
        $present_month = date("m");
        $present_year = date("y");
        for ($i=0;$i<=23;$i++){
        $query="SELECT * FROM visitors WHERE visitor_day=$present_day AND visitor_hour=$i AND visitor_minute<=59   ";
        $select_query= mysqli_query($connect, $query);
        $num_visitors[$i]= intval(mysqli_num_rows($select_query));
        array_push($total_visitors_present, $num_visitors);
        echo json_encode($total_visitors_present[0]);

and in another php file (charts.php) in script tag I have the following Ajax code

                url: 'includes/ajax_chart.php',
                type: 'POST',
                success: function (data) {

The console output is weird.

while that i expected to output is the following array
[0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
What am I doing wrong?
How i retrieve the array with ajax?

what console output do you get?

that’s a PHP error message (enhanced by XDebug). at the bottom of the image you can actually see the message itself.

1 Like

Thanks a lot Dormilich.I fix it and i hope to continue my project.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.