|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Ajax Record Getter
I have no idea what to call this. I am a PHP programmer new to Axax, JQuery etc... I'm building a classifieds site for a client and would like to have a panel with rows of classified ads that updates via AJAX every 10 seconds or so if there's new ads, w/o reloading the page. I am not sure if this site is doing that but the effect would be the same:
http://www.classifieds.myspace.com/ So every ten seconds it would query the database (maybe it has to trigger a PHP script) and check for new posts, and if so, scroll down to add one new one... Ideas on what this is called, any classes or libraries that can do it or direction to get started? |
|
#2
|
|||
|
|||
|
hi 75 miles,
jquery is a really easy way to get started espcially if you're familiar with css (in order to select items you want to manipulate) //index.html Code:
<div id="table_holder"> <table> <tr>...etc </table> </div> //index javascript Code:
<script type="text/javascript">
$(document).ready(function(){
//when the document is ready do this function
new_ad_timer = setInterval("update_ads()", 10000);
//every 10 seconds call the update_ads function
});
function update_ads() {
$("#table_holder").load("getAds.php", {category: 2, sub_cat:5}, function(){
//translates to get the element with id table_holder and load into it the echoed results of the getAds php page
//when we call getAds.php we are sending two post vars $_POST['category'] and $_POST['sub_cat'] (if something like that is useful)
//when the content has been loaded into the div element do a simple alert
alert("table updated");
});
}
</script>
getads.php would do a simple db query (perhaps using the posted values) and echo out the results in a table
__________________
working on goggle wave... it's like google wave but there's lots more beer involved |
|
#3
|
|||
|
|||
|
awesome thank you.
|
![]() |
| Viewing: Dev Shed Forums > Web Design > JavaScript Development > Ajax Record Getter |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|