How to display the PHP error message in JavaScript?

0

The problem is that to get the php data, if there is an error in php it shows an error like this:

What I want is to know how to show that error in the browser console.

I have this snippet of code in javascript using angularjs

var app = angular.module("ejemplo",[]);

app.service("ejemploSrv", function($http) {
  this.getEjemplo = (onResponse, onError) => {
    $http.get("http://localhost/ejemplo.php").then(onResponse, onError);
  }
});

app.controller("ejemploCtrl", function($scope, ejemploSrv) {
  ejemploSrv.getEjemplo((onResponse) => {
    //Si no aparece el mensaje de error de php
  }, (onError) => {
    //Si hay error en php
        console.log(JSON.stringify(onError.data));
        console.log(JSON.stringify(onError.status));
        console.log(JSON.stringify(onError.statusText));
  });
});

In the example I show in the console 3 data if there was an error in the request, which shows me undefined

    
asked by Aleex 12.10.2018 в 04:51
source

0 answers