Upload data without referredh

2

I have a form passing the data by GET to an API, the method I put empty to load on the same page, when I get the data I put inside a div to display them, but I need to do this without refreshing the page , I need to just load the did with the data, I do not have the Jquery morning.

I did this

 jQuery(document).ready(function () {

        jQuery('#ajax_form').submit(function () {

            var dados = jQuery(this).serialize();

            jQuery.ajax({
                type: "GET",
                url: "index.php",
                data: dados,
                success: function (data)
                {
                    alert('deu certo');
                }
            });

            return false;
        });
    });

But I need the data to return to a table, not an alert.

    
asked by anonymous 06.10.2018 / 19:42

1 answer

0

Make a function that receives a parameter (data-json, xml, etc.) and calls it within the success event of ajax passed the date as argument, to render the table has several modes, directly accessing the table with the DOM and changing their values, using templates, among others.

function renderTable(data) {//exemplo console.log(data); // aqui os codigo para renderizar a tabela}
    
06.10.2018 / 23:06