Reputation: 37474
If i was using this basic AJAX jQuery code:
$.ajax
({
type: "POST",
url: "email.php",
data: data,
cache: false,
success: function(html)
{
$('#success').html(html);
}
});
And i had this on a 10 second setInterval function and left it on for a day, week, month? What adverse effects would this have on a browser, in terms of cache, memory, CPU, etc?
Also, will it have any effects at all?
Upvotes: 1
Views: 361
Reputation: 7402
Unless there is memory leak, it shouldn't be a problem in theory, but the only way to be sure is to benchmark on your system in the browser of your choice.
However, you may not be using the most optimal solution for the problem: perhaps setting up a cron task on the server and testing its status from time to time using $.ajax may fit you better; that way you would save bandwidth and you wouldn't need to keep the browser open all the time.
Upvotes: 1
Reputation: 5888
My experience is that it really depends on the amount of information you're trying to send. If it's 200bytes every 10 seconds noone's gonna notice, but trying to receive 1kb every 3 seconds definitly is noticable on older pc's.
The biggest issue is probably memoery usage. If you don't carefully construct your code the garbage collecter won't be able to collect the function closures for each ajax request. This'll amount to quite a large amount of momery over time (think 1GB of ram in FireFox, over the duration of an hour).
Of course this is all personal experience and your own milage may very, but I would recommend against it.
Upvotes: 1