my problem is that I have a page with several form
to which I intend to make ajax requests so that it does not recharge the page, but I recharged it and I do not know what the reason is, I have investigated and tried in several ways, but none of them turn out to me, this is my code:
$(document).on('ready',function(){
// function enviar(){
$('#btn_predio').submit(function(event) {
alert('entro a la funcion');
event.preventDefault();
// var url = //$(this).attr('action');
var datos = $(this).serialize();
var url = "../../controller/radication_controller.php";
$.ajax({
cache: false,
type: "POST",
url: url,
data: datos,
success: function(data)
{
$('#btn_predio').reset();
alert(data);
}
});
// return false;
});
// }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<form name="frPredio" id="frPredio" method="post">
<div class="col-lg-12 form-group"></div>
<div class="col-lg-12 input-group">
<div class="col-lg-6 input-group">
<label for="dirActual" class="col-form-label col-lg-5">Dirección (Actual)</label>
<input type="text" name="dirActual" class="form-control col-lg-7">
</div>
<div class="col-lg-6 input-group">
<label for="BarrioActual" class="col-form-label col-lg-5">Barrio (Actual)</label>
<input type="text" name="BarrioActual" class="form-control col-lg-7">
</div>
</div>
<div class="col-lg-12 input-group" >
<div class="col-lg-5"></div>
<button type="button" name="btn_predio" id="btn_predio" value="predio" class=" btn btn-danger agregar col-lg-2" >
<span class="fa fa-floppy-o"></span> Guardar
</button>
</div>
</form>
In the success of the ajax I have an alert that is supposed to stop the flow of jecution, but ignores it and I reload the page.
I have tried several things, but nothing works. I appreciate the help you give me