Does anyone know why this error is coming out? SyntaxError: Unexpected token F in JSON at position 2

0

This function gives me data that comes from several queries in order to make some calculations but when I call it, it sends me directly to the error. It never enters success: function (data), does anyone know where the error is?

This is the model

    public function Siguiente_intervalo(){
    //CUAL ES EL SIGUIENTE INTERVALO DESPUES DEL INTERVALO IDENTIFICADO
    $FechaApertura = $this->input->get("FechaApertura");
    $FechaCierre = $this->input->get("FechaCierre");
    $query = $this->db->query("SELECT idFechaRango FROM rango_fecha WHERE FechaApertura= '".$FechaApertura."' and FechaCierre='".$FechaCierre."'");
    $ret   = $query->result();
    foreach ($ret as $fila) {
        $idFechaRango = $fila->idFechaRango;
    }
     // CUAL ES EL ULTIMO REGISTRO DE GASTO DE ESES SIGUIENTE INTERVALO
    $query_2 = $this->db->query("SELECT * FROM rango_fecha WHERE idFechaRango > ".$idFechaRango." limit 1");
    $ret_2   = $query_2->result();
    foreach ($ret_2 as $fila) {
        $FechaApertura_ = $fila->FechaApertura;
        $FechaCierre_ = $fila->FechaCierre;
    }
    //DATOS PARA CALCULAR EL REINTEGRO CON LOS SALDOS DEL ULTIMO REGISTRO IDENTIFICADO
    $query_3 = $this->db->query("SELECT * FROM caja_chica WHERE FechaIngreso BETWEEN '".$FechaApertura_."' AND '".$FechaCierre_."' ORDER BY idCaja DESC limit 1");
    return $query_3->result();
} 

This is the driver

public function Siguiente_intervalo(){
$result = $this->Cajachica_model->Siguiente_intervalo();
echo json_encode($result);

}

This is the function

function Siguiente_intervalo(FechaApertura,FechaCierre) {
    $.ajax({
        type: 'ajax',
        method: 'get',
        url: "<?php echo base_url();?>cajachica/Siguiente_intervalo",
        data: {FechaApertura:FechaApertura , FechaCierre:FechaCierre},
        async: false,
        dataType: 'json',
        success: function (data) {
        alert(data);
        if(data == ""){
        alert("No tiene datos");
        }
        else{
          for (i = 0; i < data.length; i++) {
                alert(data[i].tot_egresos);
                alert(data[i].saldo_efectivo);
                alert(data[i].saldo_banco);
                alert(data[i].saldo_total);
                }

        }
        },
        error: function (jqXHR, textStatus, errorThrown) {
        console.log(jqXHR.statusText);
        console.log(textStatus);
        console.log(errorThrown);
            swal({
                title: "Error!",
                text: "Ocurrio un error!",
                icon: "error",
                button: "Aceptar",
            });
        }
    });
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

The console shows me this:

console.log(jqXHR.statusText); ->  OK
console.log(textStatus); -> parsererror
console.log(errorThrown); ->
SyntaxError: Unexpected token F in JSON at position 2
at JSON.parse (<anonymous>)
at n.parseJSON (jquery.min.js:4)
at Ab (jquery.min.js:4)
at z (jquery.min.js:4)
at XMLHttpRequest.<anonymous> (jquery.min.js:4)
at Object.send (jquery.min.js:4)
at Function.ajax (jquery.min.js:4)
at Siguiente_intervalo (eval at globalEval (jquery.min.js:2), <anonymous>:670:7)
at verificar_Intervalo_Fecha (eval at globalEval (jquery.min.js:2), <anonymous>:657:7)
at Object.success (eval at globalEval (jquery.min.js:2), <anonymous>:624:6)
    
asked by Luis 22.10.2018 в 22:14
source

0 answers