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

I have implemented a system in which 10,000 calls are made to a PHP file which generates a random numbe

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744408596a4572756.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信