Why does not Ajax show php return?

0

Hello, I am using PHPExcel to import data. I've done an if in php to check if one of the cells in excel has been populated or is 0, and if true it should return an error in an array object, but Ajax does not show that return.

PHP:     

$uploadDir = "uploadFile/";

$uploadfile = $uploadDir . $_FILES['file_xls']['name'];


if(move_uploaded_file($_FILES['file_xls']['tmp_name'], $uploadfile)) {

 $objReader = PHPExcel_IOFactory::createReader('Excel2007');
 $objPHPExcel = $objReader->load($uploadfile);

 $sheet = $objPHPExcel->getActiveSheet();

 foreach ($sheet->rangeToArray($sheet->calculateWorksheetDataDimension()) as $row) {
//echo $row[0].' '.$row[1].' '.$row[2]."\n";
if($row[0] == 0 || $row[0] == ''){
  $msg = "Dado inváido";
  $return = array(
      'sucesso' => 0,
      'msg' => $msg
    );

  echo json_encode($return);
}
?>

Ajax

$scope.input = document.createElement("INPUT");
$scope.input.setAttribute("type", "file");
$scope.input.addEventListener('change', function(){
  formData.append('file_xls', $scope.input.files[0]);

    $.ajax({
      url: 'php/importaArquivo.php',
      data: formData,
      type: 'POST',
      contentType: false,
      processData: false
    })
      .then(function(response) {
        **console.log(response);**

        buscaListaCursos();
  }, function(response) {
      console.log("Error "+response);
  });
});

And always returns:

    
asked by anonymous 11.09.2018 / 13:39

0 answers