help please I have javascript function through ajax send a query to the php server but I get the error mentioned in the title. javascript function:
function buscaCliente(){
var opcion = $("#opcionBuscaC").val();
var variable=$('#variableBusca').val();
if(opcion==='0'){
}
if(opcion==='1'){
location.reload();
}
if(opcion==='2'){//ruc
var datos={'bandera':'busca','identificacion':variable, 'nombre':'vacio'};
var datosConver=JSON.stringify(datos);
//funEnvio(datosConver);
$.ajax({
type:'POST',
url:'funcionesCliente.php',
data:{parametros:datosConver},
error: function(){alert ('Error en la llamada Ajax');},
success: function(dato){
if(dato==='NO DATOS'){
alert('No se encontraron registros');
$('tbody').remove();
}else{
var datos = $.parseJSON(dato);
$('tbody').remove();
$('#clienteReporte').append('<tbody>');
$.each(datos, function(i,item){
var tr= $('<tr>').append(
$('<td>').text(i),
$('<td>').text(item.id),
$('<td>').text(item.identificacion),
$('<td>').text(item.razonsocial),
$('<td>').text(item.direccion),
$('<td>').text(item.telefono),
$('<td>').text(item.celular),
$('<td>').text(item.email),
$('<td>').append($('<a href="#">').text('VER')),
);
$('tbody').append(tr);
});
}
}
});
}}
and this is the php:
$cliente= json_decode($_POST['parametros']);
$bandera=$cliente->{'bandera'};
switch ($bandera){
case 'ingresa': insertaCliente($conexion, $cliente);
break;
case 'lista': buscaCliente($conexion, $cliente);
break;
}
//FUNCION LISTAR CLIENTE
function buscaCliente($conexion,$cliente) {
$identificacion=$cliente->{'identificacion'};
$nombre=$cliente->{'nombre'};
$consulta= "CALL PA_buscacliente('$identificacion','$nombre');";
$resultado= mysqli_query($conexion, $consulta);
if(mysqli_num_rows($resultado)==0){
echo 'NO DATOS';
}else{
while ($filas = mysqli_fetch_assoc($resultado)) {
$contenedor[] = $filas;
}
echo json_encode($contenedor,JSON_FORCE_OBJECT);
}
}