Not Solved Refresh every 5 second
#1
Not Solved
Hi,
I just noticed that my mebers is always refreshing 5 seconds (which makes them online and eventually generate lots of time spent online, which I don't wanna).

Video: https://u.pomf.is/ypteyo.mp4

NOTE: I told the user to stay on the index page without refreshing.

Can this script be causing this?

<script type="text/javascript">
 jQuery(document).ready(function(){
var interval = 5000;
var refresh = function() {
// Ajax Request 
jQuery.ajax({
url: "usercp.php?action=notification_ajax",
data: {
key: '{$mybb->post_code}'
},
type: "POST",
dataType: "html",
success: function (data) {
$('#notificationcounter').html(data);
setTimeout(function() {
refresh();
}, interval);
},
error: function (xhr, status) {
setTimeout(function() {
refresh();
}, interval);
},
complete: function (xhr, status) {
}
});
};
refresh();
});
</script>

Thanks.  Smile
Reply
#2
Not Solved
Open member_profile template and search for

{$online_status}

replace to

<span id="online_status">{$online_status}</span>

search for

{$timeonline}

replace to

<span id="timeonline">{$timeonline}</span>

add after

</table>

this

<script type="text/javascript">
var interval = 5000;
$(document).ready(function() {
 	 $("#online_status").fadeOut("fast").load(" #online_status").fadeIn("fast");
	$("#timeonline").fadeOut("fast").load(" #timeonline").fadeIn("fast");
   var refreshId = setInterval(function() {
      $("#online_status").fadeOut("fast").load(' #online_status').fadeIn("fast");
	   $("#timeonline").fadeOut("fast").load(' #timeonline').fadeIn("fast");
   }, interval);
   $.ajaxSetup({ cache: false });
});
</script>

Hope this helps Rolleyes

Addition:
The Time Spent Online time is updated only when the user clicks something in forum.
Reply
#3
Not Solved
That script probably would do it yeah as it's checking notifications every 5 seconds; that would count as activity so would update the last activity date in the user's session.
MyReactions - All Plugins

Can you still feel the butterflies?

Free never tasted like pudding.
Reply
#4
Not Solved
Just testet and works from my page.
Reply
#5
Not Solved
I'm not really sure of the relevance of your code changes to the original question to be honest.
MyReactions - All Plugins

Can you still feel the butterflies?

Free never tasted like pudding.
Reply
#6
Not Solved
Sry my bad, have misunderstood it completely.
Reply
#7
Not Solved
@MrBrechreiz, so that actually works?
Reply
#8
Not Solved
The refresh is already working, only there is not what you are looking for. Sorry.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)