William
William

Reputation: 15

refresh table without refreshing page using ajax Django

i am using ajax for updating page without refreshing in Django i want to update table but i am not using api in my views.py can i want refresh only the table

script

$.ajax({
    type:'POST',// type of the form 
    data: $('#tableid').serialize(), // all the  form name 
    success: function (data) {
        return data // i don't want all return data i want only table data it should refresh
    }   
});

Upvotes: 0

Views: 330

Answers (1)

Ahmed Elgammudi
Ahmed Elgammudi

Reputation: 746

do something like this bro take the new table data and innerHTML in old table data

$.ajax({
    type:'POST',
    data: $('#tableid').serialize(),  
    success: function (data) {
        var old_tabel_data = document.getElementById('tableid'); // old table 
        var htmlObject = $(data); 
        var new_table_data =htmlObject.find("#tableid").html(); // new table
        old_table_data.innerHTML=new_table_data;
    }   
});

Upvotes: 1

Related Questions