Search code examples
javascriptphpjsonfirebird

can't get data from json even getting a response on the console


I've been trying to send this information to the js.

$statement = ibase_prepare($sql);
    $query = ibase_execute($statement);

while ($row = ibase_fetch_assoc($query)) {
    $data[] = $row;
}
    echo json_encode($data);

However, when I try to, I get the response, but I can't get the data.

$('document').ready(function (){

 $.ajax({
    method: "POST",
    url: "../Dashboard/php/chart.php",
    dataType: "json",
    sucess: function (data){
   
      console.log(JSON.stringify(data));

    }
  });
})

Solution

  • You just have a grammatical error in a word "sucess", the correct word is "success"

      $.ajax({
          method: "POST",
          url: "./data.php",
          dataType: "json",
          sucess: function (data){ // Here -> success
            alert(JSON.stringify(data));
    
          }
        });