By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,978 Members | 1,362 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,978 IT Pros & Developers. It's quick & easy.

AJAX Refresh?

P: 22
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:
Expand|Select|Wrap|Line Numbers
  1. <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=\"javascript:document.location.reload() ;\"

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
Dec 2 '07 #1
Share this Question
Share on Google+
5 Replies


gits
Expert Mod 5K+
P: 5,351
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
Dec 2 '07 #2

P: 22
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,mysql

thats why i asked if anyone could help me do it. I read the articles and i didnt understand anything.
Dec 2 '07 #3

gits
Expert Mod 5K+
P: 5,351
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
Dec 2 '07 #4

P: 22
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
Dec 3 '07 #5

P: 22
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=\"javascript:document.location.reload() ;\"

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





Please let me know.

Thanks
Dec 3 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.