Failed SQL query from AJAX?

0

I have this code in PHP:

function getPedidos(){
  $mysqli = getConn();
  $query = "SELECT * FROM 'historial'";
  $result = $mysqli->query($query);

    $indices = '<table align='center'>
                <tr>
                    <th>NumP</th>
                    <th>Referenia</td>
                    <th>Detalles</th>
                    <th>Tipo</th>
                </tr>';

  while($row = $result->fetch_array(MYSQLI_ASSOC)){

    $indices = '<tr>
                    <td>" .$row[npedido]. "</td>
                    <td>" .$row[referencia]. "</td>
                    <td>" .$row[detalles]. "</td>
                    <td>" .$row[tipo]. "</td>
                </tr>';
  }

  $indices = '</table>';
  return $indices;
}

echo getPedidos();

The one I call from the following AJAX code:

$(document).ready(function(){
  $.ajax({
    type: 'POST',
    url: 'php/cargar_historial.php'
  })
  .done(function(listas_rep){
    $('#historial').html(listas_rep)
  })
  .fail(function(){
    alert('Hubo un errror al cargar el historial de pedidos')
  })
})

** What I think ... is that I lost my hand when creating the table in php **

The ajax, happens to me by .fail, thing, that I do not find the fault. Someone could help me? Thank you very much!

    
asked by Javier Avila Fernandez 27.08.2018 в 19:35
source

0 answers