Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2010
    Posts
    99
    Thanks
    10
    Thanked 1 Time in 1 Post

    Polling for database changes?

    Hello all,
    I am slightly confused and overwhelmed. I would like to set up a notification system on my web application. I have found lots of quick snippets of polling, but nothing that really shows me how to put it all together.

    Code:
    function doPoll(){
        $.post('ajax/test.html', function(data) {
            alert(data);  // process results here
            setTimeout(doPoll,5000);
        });
    }
    If a user is idle on a page, I want to check a certain table for changes every 5 second or whatever. If a change is detected, it will notify the user with some kind of notification system (such as Freeow!) or something similar.

    How do I fire the alert? What do I check for on my server side page? How do I tie the polling into a notification? These are some of the questions I just can't find any answers or examples for.

    Can anyone help??

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    Google "web sockets" and "long polling".

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,294
    Thanks
    10
    Thanked 583 Times in 564 Posts
    i would use EventSource if i were you, it's way easier than sockets on the backend (its just http), and way less sucky than ajax2 or jsonp long-polling.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •