I am working on a networking site where I need to reload the notification div every second. I wanted to know is it good or bad to load it every second as there are some other divs also loading after every 3-4 seconds. Will it cause any problem like hanging, slowing down, etc?
Reloading is done by ajax:
var auto_refresh = setInterval(
function () {
$('#notif').load('notiffinder.php #NOOFFNOTIFFC').fadeIn();
$('#jtoloadnot').load('header.php #jtoloadnot').fadeIn();
}, 1000);
1
We can’t tell you if it will cause problems because it entirely depends on what you are putting into that div, your internet connection, and what kind of load you have on the server.
But you need to ask yourself, do you really need to be polling multiple php scripts every second? Is the data actually changing every second? I suspect you probably should be investigating other techniques, such as websockets and long-polling.
2