skip to Main Content

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


  1. 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

    Login or Signup to reply.
  2. Try to write the full url path from which you are fetching the data.

    function check_new_data(){
    $.post("http://example.com/get_new_data",{},function(e){
    if(e!=""){
    }
    });
    }
    var interval = 0
    setInterval(check_new_data(), interval);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search