I am making an application where I need to check the database if new data is available to show. For that in JQuery I am doing:
function check_new_data(){
$.post("./get_new_data",{},function(e){
if(e!=""){
//do something
}
});
}
var interval = 0
setInterval(check_new_data(), interval);
This is working good in localhost server but when I upload my site to the live server it crashes my site and makes site unreachable for sometime.
2
Answers
You are using
interval = 0
. That means infinite requests. This will not harm your localhost but can harm your live server.https://stackoverflow.com/a/63604449/11910869
Try to write the full url path from which you are fetching the data.