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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.