Help, I have a big problem with ajax, I deleted records using ajax, using confirmation window bootstrap, very well when I press the button to delete it runs correctly and the table refreshes without any problem, the problem is that when I want to remove another record, opens the modal window bootstrap, but do not run anything
<head>
<script type="text/javascript" language="Javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script data-require="jquery@*" data-semver="2.0.3" src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<script data-require="bootstrap@*" data-semver="3.1.1" src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<link data-require="bootstrap-css@3.1.1" data-semver="3.1.1" rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
<!--<script type="text/javascript" language="Javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>-->
</head>
<script type="text/javascript" >
var base_url = '<?php echo base_url() ?>clientes/eliminar';
$('#confirmar').click(function (e) {
var modalDiv = $(e.delegateTarget);
var id = $(this).data('recordId');
$('#confirm-delete').addClass('loading');
setTimeout(function () {
modalDiv.modal('hide').removeClass('loading');
}, 100000);
$.ajax({
type: "POST",
url: base_url,
data: "idcliente=" + id,
beforeSend: function () {
//$('#msgUsuario').html('<span></span>');
},
success: function (respuesta) {
$('#confirm-delete').hide();
$('.modal-backdrop').hide();
$('#contenedor2').html(respuesta);
}
});
});
// Bind to modal opening to set necessary data properties to be used to make request
$('#confirm-delete').on('show.bs.modal', function (e) {
var data = $(e.relatedTarget).data();
$('.title', this).text(data.recordTitle);
$('.btn-ok', this).data('recordId', data.recordId);
});
});
</script>
<style>
.modal.loading .modal-content:before {
content: 'Loading...';
text-align: center;
line-height: 155px;
font-size: 20px;
background: rgba(0, 0, 0, .8);
position: absolute;
top: 55px;
bottom: 0;
left: 0;
right: 0;
color: #EEE;
z-index: 1000;
}
</style>
<li><a data-toggle="modal" data-target="#events-modal">Nuevo Cliente</a></li>
<div id="contenedor2" class="col-md-8 col-md-offset-2">
<table >
<tr>
<th class="col-xs-4" style="text-align:left;border:1px solid">Name</th>
<th class="col-xs-4" style="text-align:left;border:1px solid">tel</th>
<th class="col-xs-2" style="text-align:center;border:1px solid">Email</th>
<th class="col-xs-1" style="text-align:center;border:1px solid">Edit</th>
<th class="col-xs-1" style="text-align:center;border:1px solid">Delete</th>
</tr>
<tbody class="tablenotas">
<?php
if (is_null($lista)) {
echo "<h4>Para comenzar presiona el botón Nuevo</h4>";
} else {
$base = base_url();
foreach ($lista as $fila):
echo '<tr style="text-align:justify">' .
'<td style="text-align:left;border:1px solid">' . $fila->NombreCliente . '</td>' .
'<td style="text-align:left;border:1px solid">' . $fila->RazonSocial . '</td>' .
'<td style="text-align:center;border:1px solid">' . $fila->Email . '</td>' .
'<td style="text-align:center;border:1px solid"><a href="' . $base . 'clientes/detalles_cliente/' . $fila->Id_Cliente . '"><span class="glyphicon glyphicon-edit"></span></a></td>' .
'<td style="text-align:center;border:1px solid"><a href="#" data-record-id="' . $fila->Id_Cliente . '" data-toggle="modal" data-target="#confirm-delete"><span class="glyphicon glyphicon-trash"></span></td>' .
'</tr>';
endforeach;
}
?>
</tbody>
</table>
<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Confirm Delete</h4>
</div>
<div class="modal-body">
<p>Estás a punto de eliminar <b><i class="title"></i></b> el registro, este procedimiento es irreversible.</p>
<p>Desea proceder?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
<button type="button" id="confirmar" class="btn btn-danger btn-ok">Continuar</button>
</div>
</div>
</div>
</div>
</div>
in my controller
function delete() {
$idcliente = $this->input->post('idcliente');
if ($this->ion_auth->is_admin()) {
if ($this->Cliente_model->delete($idcliente)) {
$this->_data['lista'] = $this->Cliente_model->getClientes();
$this->load->view('user/clientes', $this->_data);
}
}
}