AJAX Refresh?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kaante
    New Member
    • Dec 2007
    • 22

    AJAX Refresh?

    Hi,

    I basically have two frames on my page, the top one contains users stats and the bottom frame contains the website.

    I want to have a message icon on the top frame which would flash once the user gets a new message. Obviously I would have one message icon which doesn't flash and another which does.

    Right now i refresh the top frame every 30 seconds so that the stats update. But is there an easier way to refresh? I mean right now the whole top frame refreshes which can get annoying.

    I was told to use AJAX to refresh the values, instead of the whole frame.

    I currently use this html code to refresh the whole frame:
    Code:
    <META http-equiv="refresh" content="10">

    The part i want to refresh is:
    [PHP]
    <?php
    if ($inbox > 0){ echo "<a href=inbox.php target=middle>< img border=0 src=images/unread1.gif align=left width=16 height=11></a> ";
    }else{ echo "<img src=images/read.gif align=left width=16 height=11>"; }

    if ($inbox > 0){ echo "<span style=FONT-WEIGHT:bold><a href=inbox.php



    ONMOUSEOUT=\"ja vascript:docume nt.location.rel oad();\"

    target=middle>< font color=#990066>$ inbox New </a></font></span>"; } ?>[/PHP]



    Please let me know how to apply an AJAX code to it so that the message status is updated.

    Thanks
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    hi ...

    welcome to TSDN ...

    that is a very basic question ... you should have a look at some ajax-tutorials ... or for a quickstart look at this article. in your top-frame you should make an ajax-request that calls the input.php with setInterval(); ... so that would be the idea, now try something and come back in case you have specific questions about it ...

    kind regards

    Comment

    • Kaante
      New Member
      • Dec 2007
      • 22

      #3
      Originally posted by gits
      hi ...

      welcome to TSDN ...

      that is a very basic question ... you should have a look at some ajax-tutorials ... or for a quickstart look at this article. in your top-frame you should make an ajax-request that calls the input.php with setInterval(); ... so that would be the idea, now try something and come back in case you have specific questions about it ...

      kind regards
      i don't know anything about AJAX, i work with php,css,html,my sql

      thats why i asked if anyone could help me do it. I read the articles and i didnt understand anything.

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        hi ...

        ok ... in case you don't have any clue ... read this first ... it gets you ontrack ... the article i told you before shows the code you would need for your task ... it is not that much ... but i makes no sense to rewrite an ajax-tutorial here.

        quick-walkthrough:

        basically you need a instance of a XMLHttpRequest-Object. now you set some properties of that object and call some methods ... send it with a querystring to your server ... the instance waits for the response and handles it, when the response is send back to the client ... the handling is a function you write for yourself ... so you may update a div if you want :) ... read the above article carefully its not very complicated ...

        kind regards

        Comment

        • Kaante
          New Member
          • Dec 2007
          • 22

          #5
          Originally posted by gits
          hi ...

          ok ... in case you don't have any clue ... read this first ... it gets you ontrack ... the article i told you before shows the code you would need for your task ... it is not that much ... but i makes no sense to rewrite an ajax-tutorial here.

          quick-walkthrough:

          basically you need a instance of a XMLHttpRequest-Object. now you set some properties of that object and call some methods ... send it with a querystring to your server ... the instance waits for the response and handles it, when the response is send back to the client ... the handling is a function you write for yourself ... so you may update a div if you want :) ... read the above article carefully its not very complicated ...

          kind regards
          i appreciate your help, however i think i won't be able to do this myself. So i am willing to pay someone a small amount ($20) via paypal to code this small refresh feature.

          If you or anyone could help me with this then please contact me.

          Thanks

          Comment

          • Kaante
            New Member
            • Dec 2007
            • 22

            #6
            AJAX Refresh?

            Hi,

            I basically have two frames on my page, the top one contains users stats and the bottom frame contains the website.

            I want to have a message icon on the top frame which would flash once the user gets a new message. Obviously I would have one message icon which doesn't flash and another which does.

            Right now i refresh the top frame every 30 seconds so that the stats update. But is there an easier way to refresh? I mean right now the whole top frame refreshes which can get annoying.

            I was told to use AJAX to refresh the values, instead of the whole frame.

            I currently use this html code to refresh the whole frame:

            [HTML]<META http-equiv="refresh" content="10">
            [/HTML]

            The part i want to refresh is:

            [PHP]<?php

            if ($inbox > 0){ echo "<a href=inbox.php target=middle>< img border=0 src=images/unread1.gif align=left width=16 height=11></a> ";

            }else{ echo "<img src=images/read.gif align=left width=16 height=11>"; }



            if ($inbox > 0){ echo "<span style=FONT-WEIGHT:bold><a href=inbox.php

            ONMOUSEOUT=\"ja vascript:docume nt.location.rel oad();\"

            target=middle>< font color=#990066>$ inbox New </a></font></span>"; } ?>[/PHP]





            Please let me know.

            Thanks

            Comment

            Working...