Jump to content

using ajax to poll calendar events & display reminder


playaz

Recommended Posts

Hi guys,

 

I've not done too much AJAX in the past so feel free to correct me if I am wrong on any occasion..

 

I want to poll an events database table every 60 seconds, and run an mysql query to grab all upcoming events, an upcoming event should pop up to screen ideally in a modal window.

 

Can anyone suggest how I could do this or point me in the right direction - thanks in advance.

I've done the following - it all works too! I just want to perform a simple alert() if the ajax returns succesfully - here is my code

 

Note - post.php just does a select statement limited to 1 row (this works fine and returns an array to the #responsecontainer)

 

Can anyone explain how i'd change the code to do this:-

1) if ajax returns succesfully pop up an alert box

2) the returned content in the responsecontainer is always string but the post.php returns an array (i'm guessing some json maybe required?) How can I get this returned content as an array and not a string (as i'll need for another function for creating a jquery dialog box.

 

<script>
$(document).ready(function() {
         
   var refreshId = setInterval(function(){
    		$.ajax({
    			type: "POST",
    			url: "post.php",
                        data: 	"",
    			success: function(html){
    				$("#responsecontainer").html(html);
    			}
    		});		
        }, 1000 );
        
});
</script>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.