Jquery - Update list by ajax

Asked

Viewed 65 times

1

I have an ajax that is called every 10 seconds by a setInterval, it gets a json and when I delete an item from the json I need the item to sum up from the ajax listing as well, the code to remove the item from the listing is $( "#item" + data.data[i].item ).remove();, just need an if for this, follow example:

success: function (data) {
    $.each(data.data, function(i, it) {
        if ( $( "#item-" + data.data[i].item).length ) {
             $( "#item-" + data.data[i].item+ " h2" ).html(data.data[i].item);
        }
    });
}

In the example it updates the item coming from ajax json...

No answers

Browser other questions tagged

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