Hello, good morning, I have the following problem. I have a controller reg_calls_controller.php which has its function index and load the view reg_calls_view.php , in the html I have several things in between button that calls to the following JavaScript function .
function msj_cargando() {
$('#modalLoad').modal('show');
$.ajax({
url : "<?php echo base_url('index.php/reg_calls_controller/todas_calls/')?>",
type: "POST",
dataType: "JSON",
success: function(data) {
console.log(data);
//alert(data);
$('#modalLoad').modal('hide');
},
error: function (jqXHR, textStatus, errorThrown) {
alert(textStatus);
$('#modalLoad').modal('hide');
swal({
title: "Error!",
text: "La conexion no fue exitosa!",
icon: "error",
button: true,
dangerMode: false,
});
}
});
}
In the JS first I show the following modal that is in reg_calls_view.php and I use it as a loading.
<div id="modalLoad" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-body text-center"">
<i class="fa fa-spinner fa-spin fa-5x"></i>
<p><h3>Cargando...</h3></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Cancelar</button>
</div>
</div>
</div>
</div>
But what I try to do is to show that modal while I call the function all_calls which is the same in reg_calls_controller.php and this function at the same time make a query the results send them all_calls_view.php and finally the modality is closed.
public function todas_calls() {
$sess_array = array(
'id_user' => $this->session->userdata['sess_data']['id_user'],
'username' => $this->session->userdata['sess_data']['username']
);
$data = array();
$data['sess_data'] = $sess_array;
$data['todas_calls'] = $this->reg_calls_model->todas_calls();
$data['menu_higher'] = $this->load->view('elementos/menu_higher_view.php', $data, TRUE);
$data['menu_left'] = $this->load->view('elementos/menu_left_view.php', '', TRUE);
echo json_encode($data);
$this->load->view("todas_calls_view.php", $data);
}
I hope you can help me.