I am trying to run a json which I previously obtained from php. But when I try to run it to show it, it sends me this error in the console.
I'm new to javascript and ajax, my goal is that json, is an array of a query made in mysql, when I print it by console, if the result is normal. but my problem is to cross it since I need to show the list in a select.
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="last-name">Relacion<span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="number" id="relacion" name="txtRelacion" required="required" class="form-control col-md-7 col-xs-12">
<script type="text/javascript">
$(document).ready(function(){
$("#btnB").on('click',function() {
var relacion = $("#relacion").val();
$.ajax({
// metodo: puede ser POST, GET, etc
method: "POST",
// la URL de donde voy a hacer la petición
url: "listprov.php",
// los datos que voy a enviar
data: { rel: relacion},
datatype : "JSON",
// si tuvo éxito la petición
success: function(listP) {
var datos = "";
var select = $("select[name=cboIdEmpresa]");
console.log($.parseJSON(JSON.stringify(listP)));
var listP = $.parseJSON(JSON.stringify(listP));
select.empty();
select.append('<option value="0">Seleccione el proveedor de Nivel</option>');
$.each(listP,function(idProveedor,nombre){
select.append('<option value="' + listP.idProveedor + '">' + listP.nombre+ '</option>');
});
}
});
});
});
</script>
<label>Proveedor:</label>
<select id="selectA" name="cboIdEmpresa" class="form-control">
?>
<option value="-1">Seleccione el Proveedor de Nivel </option>
</select>