Avoid the full refresh of the page by sending function get in jquery ajax

0

Hello, I have two functions in jQuery that when you click on the button btn_enviar send the data to the database via AJAX.

I also have a $.get that writes the data in HTML controls.

I would like to be able to send the data without refreshing the entire page, and only update the drivers.

This is the code I have:

$(document).ready(function (){
    $.get("<?php echo base_url('obteneract') ?>","",function(data){

        console.log(data);
        var json1=JSON.parse(data);
        var actividad="";

        for(post in json1){
            actividad+="<li>"+json1[post].Nombre+"</li>";
            $("#actividades").html(actividad);
        }
    });

});

$("#btn_enviar").click(function(){

    var data=$("#formulariocurso :input").serializeArray();
    $.post($("#formulariocurso").attr("action"),data, function(info){

    });
});
    
<input type="text" placeholder="Descripcion actividad" id="Actividad" name="Actividad" required>
<button class="button expanded"  id="btn_enviar"> Registrar Curso </button> 
    
asked by Alexx Galeas 09.05.2017 в 02:43
source

1 answer

-1

I think you need to read a bit about Ajax and its utility for asynchronous communications between client and server, without the need to reload the page.

I think here There is a good example. And here a bit more conceptual.

Other related questions: How make a query using ajax from a combobox and execute php function at the click of a button .

    
answered by 09.05.2017 в 03:10