zurev — 2010-12-09T07:11:24-05:00 — #1
Ok so I'll be honest, I have a good amount of experience with php/mysql, I've just started learning jQuery and I've done very little, but some with ajax. So using the terms ajax/jquery interchangeably are a bit confusing to me. Anyway as the title suggest I have a website with 5 items, and I want them to move (meaning, if a more recent one is entered, remove the last item, and put the new one on top), they are 5 of the most recent items in the database table, now I've coded jquery as a test so it fades out the last one, the whole thing moves down, makes room at the top, and fades in a new one. However, it's a test and has 0 interaction with the database, the one that fades in is just in a hidden div. So the jQuery part is taken care of.
So I'm unsure how to go about this, I was thinking maybe have ajax check a website off the page that has those 5 items in raw format, and if they change then to refresh?
Not looking for a "plz code 4 me" answer, just the concept of how it would work, or some links to get off to the right start.
karl_oakes — 2010-12-09T07:47:04-05:00 — #2
Hi, you will need to perform an ajax request if you want to collect the latest items from a DB without a page refresh. You also have the issue of when to instigate the refresh, is this going to be a page element event, i.e. (button click) or a implicit refresh interval created by JS, i.e. using setInterval, hope this helps...:)
zurev — 2010-12-09T08:20:16-05:00 — #3
I actually sort of lied. Hopefully this will help, it complicates things a bit:
Say I have 5 items that can be ranked, so if I click item 3 and it ranks above item 2, I need it to swap places refreshlessly, should I have the ajax request done every time a vote is initiated, or would that cause too much overhead if the site were to become popular?
karl_oakes — 2010-12-09T08:34:55-05:00 — #4
You will have to perform an ajax request everytime a vote is initiated as you will need to get the accurate ranking from the DB as there could be many people using your app and updating the DB.