Ajax - Auto Updating on Page, pulls from MySQL - possible?

Discussion in 'JavaScript' started by NewTier, May 15, 2009.

  1. #1
    I want to make a site that auto updates, live, by pulling numbers from a mysql database.

    How do I do this?
     
    NewTier, May 15, 2009 IP
  2. Syndrom

    Syndrom Peon

    Messages:
    89
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Well, just create a backend with php/asp and use the set time out function to crap the newest information on a time basis.
     
    Syndrom, May 15, 2009 IP
  3. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #3
    that's pretty much what ajax is for..You have a javascript that uses xmlhttprequest (or similar for older browsers) that loads a server-side file (whatever server-side language you use) which returns an XML response or similar, the javascript then parses this response and displays the data appropriately. This process can be repeated at intervals using setTimeOUt (as mentioned above) to load new data without any user interaction and without the page refreshing.
     
    camjohnson95, May 15, 2009 IP
  4. marty

    marty Peon

    Messages:
    154
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yes you can. Using the xmlhttprequest like camjohnson95 wrote is the best way to do that. Another way you could do it is with a hidden IFrame.
     
    marty, May 15, 2009 IP
  5. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #5
    Another thing. if you use ASP.NET, it has built in ajax controls such as UpdatePanel and Timers which make the process much easier.
     
    camjohnson95, May 15, 2009 IP
  6. NewTier

    NewTier Notable Member

    Messages:
    2,201
    Likes Received:
    196
    Best Answers:
    0
    Trophy Points:
    250
    #6
    Does anyone have specific code to give me an example on how this would work?
     
    NewTier, May 16, 2009 IP