I'm trying to do a function with call AJAX to php but when I click the button it shows this error, some one knows how can I solve it? My code below.
PHP:
$app->get('/checker', function () {
$jsonContents = file_get_contents('data/data.json');
$data= json_decode($jsonContents, true);
foreach ($data as $key =>[$value]) {
$host = $value['domain'];
exec('ping -c 2' . $host,$output,$result);
ECHO $result;
}
});
JS AJAX:
function CallChecker() {
$.ajax({
type: 'GET',
url: 'api/checker',
dataType: 'json',
success: function(data) {
alert(data)
}
});
}