最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Failed to load resource: net::ERR_INSUFFICIENT_RESOURCES with looped ajax query - Stack Overflow

programmeradmin4浏览0评论

I have implemented a system in which 10,000 calls are made to a PHP file which generates a random number for each call and stores it in a database table. However, I am receiving the error regarding insufficient resources. Upon evaluating the database table, it seems that 4,000 numbers have been stored successfully despite the error messages.

Below is the javascript code containing the ajax calls:

     function randNoCall() {
        $.ajax({
          url: "randomNum.php",
          method: "GET",
          success: function (res) {
            console.log(res);
            callsMade++;
            if (callsMade == 9999) {
              $("p").html(" <table> <tr><th>Number Generated</th><th>Instance Name</th> </tr> " + res + "</table> <br/>   <button id='evaluateButton' onClick='Evaluate()'>Evalaute</button> </br>");
            }
          },
        });
      }
      var i;
      var callsMade = 0;
      for (i = 0; i < 10000; i++) {
        randNoCall();
      }

The res variable returns the table data, meaning the numbers generated, in a table.

I have implemented a system in which 10,000 calls are made to a PHP file which generates a random number for each call and stores it in a database table. However, I am receiving the error regarding insufficient resources. Upon evaluating the database table, it seems that 4,000 numbers have been stored successfully despite the error messages.

Below is the javascript code containing the ajax calls:

     function randNoCall() {
        $.ajax({
          url: "randomNum.php",
          method: "GET",
          success: function (res) {
            console.log(res);
            callsMade++;
            if (callsMade == 9999) {
              $("p").html(" <table> <tr><th>Number Generated</th><th>Instance Name</th> </tr> " + res + "</table> <br/>   <button id='evaluateButton' onClick='Evaluate()'>Evalaute</button> </br>");
            }
          },
        });
      }
      var i;
      var callsMade = 0;
      for (i = 0; i < 10000; i++) {
        randNoCall();
      }

The res variable returns the table data, meaning the numbers generated, in a table.

Share Improve this question edited May 16, 2021 at 19:04 Mar asked May 16, 2021 at 18:16 MarMar 1161 silver badge10 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

After researching the issue, I noted that this issue occurred due to my browser running out of resources to handle all the requests at once. To solve this, I created a button and an onClick function which made 1,000 calls, this way separating the requests, ensuring that the browser has enough resources to handle them accordingly.

发布评论

评论列表(0)

  1. 暂无评论