Load data without refersh

Asked

Viewed 47 times

2

I have a form passing the data by GET to an API, the method put empty to load on the same page, when they return the data I put inside a div to display them, but I need you to do this without refreshing the page, I need you to only load the Did with the data, I don’t have the Jquery tricks.

I did that

 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 and not to an Alert.

  • I think the problem is that you still don’t know much about javascript, maybe studying a little more pure language is a good idea before trying frameworks and libraries. An observation, the attribute success is obsolete in the latest versions has been replaced by the function done, take a look at the documentation

1 answer

0

Make a function that receives a parameter(data-json, xml, etc) and call it inside the event sucess from ajax past the date as argument, to render the table has several modes, accessing directly the table with the DOM and changing its values, using templates, among others.

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.