{"id":2281,"date":"2022-08-30T15:23:33","date_gmt":"2022-08-30T15:23:33","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/01\/05\/ajax-polling-crashing-the-browser-as-its-memory-usagecpu-utilization-continously-increasing-any-alternative-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:23:33","modified_gmt":"2022-08-30T15:23:33","slug":"ajax-polling-crashing-the-browser-as-its-memory-usagecpu-utilization-continously-increasing-any-alternative-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/ajax-polling-crashing-the-browser-as-its-memory-usagecpu-utilization-continously-increasing-any-alternative-collection-of-common-programming-errors\/","title":{"rendered":"Ajax polling crashing the browser as its memory usage,cpu utilization continously increasing ? Any alternative-Collection of common programming errors"},"content":{"rendered":"<p>I am new to the ajax polling and i implemented to fetch data continuously , But the problem i am getting is Memory usage and CPU utilization is continously keep on increasing and in the last the browser is crashing . Here is ajax call what i am using to fetch data continuously .<\/p>\n<pre><code>$(document).ready(function () {\n\nmake_call();\nfunction make_call() {\n$.ajax({\nurl: \"url\",\n              accepts: \"application\/json\",\n              cache: false,\n              success: function (result) { \/\/ Some code here },\ncomplete: make_call\n});\n}\n}\n<\/code><\/pre>\n<p>Is there any other alternative , or am i doing something wrong . Please provide some suggestion or solution . Thanks in advance .<\/p>\n<ol>\n<li>\n<p>Your code initializes a new request at the same moment the previous requests completes (complete being either an error or success). You likely want to have a small delay before requesting new data &#8211; with the benefit of reducing both server and client load.<\/p>\n<pre><code>$.ajax({\n  \/\/ ...\n  complete: function() {\n    setTimeout(make_call, 5000);\n  }\n});\n<\/code><\/pre>\n<p>The above code waits for 5 seconds before making the next request. Tune the value to your needs of &#8220;continuous&#8221;.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2014-01-05 09:49:16. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I am new to the ajax polling and i implemented to fetch data continuously , But the problem i am getting is Memory usage and CPU utilization is continously keep on increasing and in the last the browser is crashing . Here is ajax call what i am using to fetch data continuously . $(document).ready(function [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2281","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2281"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2281\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}