Skip to content
Advertisement

is there a way to update a div with new content only using ajax

This is the div that i am updating

but i want to add a active class to the (li) item every time the div refreshes the active class goes away so i don`t want to refresh all the data in the (ul) but only add (li) if there is a new data in the database, with out refreshing the previous (li) items

JavaScript

this is my ajax call

JavaScript

in the room php

JavaScript

the get_rooms() function

JavaScript

Advertisement

Answer

You Just need to push new data to the div as below just replace your line with:

JavaScript

this will add new <li> in your existing <div> after the last <li>

jquery append()

To get the id of the last <li>

JavaScript

Once you get the last id then pass it in your ajax call.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement