Login     Sign up
alerts using ajax
Jcow Master (@falcone)
Join date: Sep 2nd 2010
Community posts: 917
View Profile
Send Message

an alert when there is a new friend request, message or notification without refresching the browser, with other words, the facebook way.

167 months ago
Abhimanyu (@abhimanyusharma003)
Join date: Aug 12th 2010
Community posts: 124
View Profile
Send Message

ya. it's good i also like this..

167 months ago
adil (@adil)
Join date: May 9th 2010
Community posts: 202
View Profile
Send Message

I'm using this code in my facebook style replace
this
[code]
echo '

    <script type="text/javascript">

setInterval(function() {
$("#vbar").load(location.href+" #vbar>*","");
}, 30000);

</script>

<td valign="bottom" align="right">'.url('u/'.$client['uname'],t('Profile')).' | <span  id="vbar"> '.$friendslink.'&nbsp;:&nbsp; '.url('message',t('Inbox').msg_unread() ).' &nbsp;:&nbsp; '.url('notifications',t('Notifications').note_unread()).' </span>&nbsp; | '.url('account',t('Account')).' | <span class="sub">'.url('member/logout',t('Logout') ).' </span>
</td>';

[/code]
with the else around line 100 in the page.tpl.php

but I've a problem that after the first refresh the line collapse and no spaces between word ... I'm still using it anyway ... if you solve the bug let me know!!

167 months ago
Abhimanyu (@abhimanyusharma003)
Join date: Aug 12th 2010
Community posts: 124
View Profile
Send Message

I have tried this..
but it does not display any message in ajax like facebook

167 months ago
Jcow Master (@falcone)
Join date: Sep 2nd 2010
Community posts: 917
View Profile
Send Message

i made some changes in one line and the space and | problem seems to be disapeared

<script type="text/javascript">
setInterval(function() {
[b]$("#vbar").load(location.href+" #vbar");[/b]
}, 9000);

</script>

i guess with simular lines of code we also can update the activity and comment streams

167 months ago
adil (@adil)
Join date: May 9th 2010
Community posts: 202
View Profile
Send Message

yes but be carefull if the member was writing a comment or a blog at the moment of the refresh his/her writing will be lost!!!!

thanks for solving my bug

167 months ago
Jcow Master (@falcone)
Join date: Sep 2nd 2010
Community posts: 917
View Profile
Send Message

there is still something wrong with the code.

if you go to photos for example, it refreshes also the photo (total views counter goes up)

167 months ago
adil (@adil)
Join date: May 9th 2010
Community posts: 202
View Profile
Send Message

that is why I alert you... the code only good for refreshing the top bar not the whole page

167 months ago
Jcow Master (@falcone)
Join date: Sep 2nd 2010
Community posts: 917
View Profile
Send Message

and why the whole page is refreshing?

the profile counter doesn't seems to have the same problem.

btw, your origninal code (with the *) is working too, if you put another span-tag within the span-tag with id vbar.

167 months ago
DeFender (@defender)
Join date: Oct 1st 2010
Community posts: 167
View Profile
Send Message

yes, it is refreshing whole page, someone have solved this?

162 months ago
Jcow Master (@falcone)
Join date: Sep 2nd 2010
Community posts: 917
View Profile
Send Message

if it is refreshing the whole page, your htlm code is not correct.

162 months ago
DeFender (@defender)
Join date: Oct 1st 2010
Community posts: 167
View Profile
Send Message

dj jcowcodemaster and how I can solve this problem, whaat tags I need to chek.

162 months ago
1 2 Next