Question
Create a few days ago a select
which is completed automatically by a DB
, I asked for help to create a container
that had the necessary fields brought from the db
, the problem is that when try to do it by AJAX method to bring the data and complete the table this gives me an error and I can not find where it is located or what is the problem of the transfer of data.
It would be very helpful if someone tells me where my error is.
JS code
$(document).on('click', '#boton_asignar',function traer_usuarios(){
$.ajax({
type: 'POST',
url: 'api/traer_usuarios',
data: $('#form_usuario').serialize(),
success: function(json) {
if (json.success == 1) {
var usuariosNoAsignados = json.usuariosNoAsignados;
var usuariosAsignados = json.usuariosAsignados;
var mostrarTodo = $('<!-- Default box --><div class="box" id="caja_secundaria"><!-- Custom Tabs (Pulled to the right) --><div class="nav-tabs-custom"><ul class="nav nav-tabs pull-rigth"><li class="active"><a href="#tab_2-2" data-toggle="tab"><label for="">Usuario</label></a></li><li class="pull-left header"></li></ul><div class="tab-content"><div class="tab-pane active" id="tab_1-1"><div class="row"><div class="col-md-6"><label for="">Usuarios no asignados</label></div><div class="col-md-6"><label for="">Usuarios asignados</label></div></div></div><!-- /.tab-pane --></div></div></div>');
$('#mostrarDatos').prepend(mostrarTodo);
for (var i = 0; i < usuariosNoAsignados.length; i++) {
$('#ejecutivos').append('<option class="opcion" value="' + usuariosNoAsignados[i][0] + '">' + usuariosNoAsignados[i][0] + '</option>');
}
// AQUI PONER EL ELSE DE LA WEA
}
},
error: function( /*xhr, status*/ ) {
msg_box_alert(/*xhr.responsetext*/);
}
});
});
PD: I work in a framework called Ocrend, therefore the URL is a REST API that sends me from the POST to the model and there it looks for the corresponding function, after the model sent the data back as variables per message.
Error message:
Here is the folder where you arrive from JS
Error typing the URL on the page:
Here I leave an API that works in the same way, this is functional and does not give me problems: