Home » Jquery » javascript – How to solve Uncaught ReferenceError: data is not defined

javascript – How to solve Uncaught ReferenceError: data is not defined

Posted by: admin February 22, 2020 Leave a comment

Questions:

I am trying to pass the value of the selected option to ajax call it returns the the following error

Uncaught ReferenceError: data is not defined 

as follows

enter image description here

Here is my js fiddle

https://jsfiddle.net/ozxtjb8p/

Here is my PHP code

month_table.php

<?php
include('conn.php');
$action = $_POST["rta_main"];
$ryear = $_POST["curr_year"];

if($action){

   $sql_curr_all_query = "SELECT MONTH(service_date) AS months,COUNT(*) AS total_calls FROM orders WHERE YEAR(service_date) = YEAR($action) AND sla_osla IN ('sla','osla') GROUP BY MONTH(service_date)";
    echo $sql_curr_query;
            $sql_curr_all_fetch = mysqli_query($conn,$sql_curr_all_query);

                while($sql_curr_all_rows = mysqli_fetch_assoc($sql_curr_all_fetch)){
                    $sql_curr_all_result[] = $sql_curr_all_rows;
                }
}
?>
How to&Answer: