SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)

    Ajax does a check - then force a page refresh?

    Hi,

    I hope I am in the correct forum for this question.

    (it certainly feels a bit like kromeys recent question)

    I have a results service page which needs to check back to the server once every minute or so to see if a number has changed. This will go on for a number of hours. In the past I just did a straight html refresh using meta tags which resulted in millions of hits as people were just looking at pages.

    This time I am also putting out rss feeds to try and reduce the traffic.

    Is there a way of getting Ajax to check a number on the server, and then somehow provoking the browser to refresh the whole page? One idea I had was somehow resetting a JS refresh timer?

    I mean I don't think its possible, and I dont particularly want to go Kromeys route of having x amount of ajax requests ... but if you dont ask ...

    Thanks for any tips.

  2. #2
    <?php while(!sleep()){code();} G.Schuster's Avatar
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well - you _have_ to send requests to the server in order to get the current number, there's no way around.
    But with AJAX (better: JS) you can reduce the traffic to a minimum.

    For example use the http://script.aculo.us periodical updater: http://wiki.script.aculo.us/scriptac...iodicalUpdater
    It calls a nice little script that only returns the number - then you check with JS if the result is what you expect and then just execute a window.reload();

    Simple, eh?

  3. #3
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    window.onload, yeah, thanks - will take a look at that.

    thanks for your help.


Bookmarks

Posting Permissions

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