title: Failed to load resource under Chrome! Not work ajax currently
body: <p>I am using this ajax code for checking domains. For each domain, a request is sent to API. I create 2000 rows in textarea with 3 suffixes (6000 domain) and click on submit. After submit all domains checked and display domain status in the table with ajax. In the first time display table of domains but after a few second table removed and code not display result! </p>
  
  <p>How to fix this problem?</p>
  
  <p>Chrome's console displays this error: </p>
  
  <pre>
  Failed to load resource: net::ERR_INSUFFICIENT_RESOURCES
  </pre>
  
  <p><strong><a href="http://totaldesign.ir/demo/adda/" rel="nofollow">Demo Link</a></strong></p>
  
  <p>Ajax code(ajax.js):</p>
  
  <pre class="lang-js prettyprint-override"><code>$(document).ready(function () {
      $("#submit").click(function () {            
  
          // check if anything is selected:
          if(!$('#domains').val() || !$('[type="checkbox"]:checked').length){
              return false;
          }
          // disable the button:
          var btn = $(this).prop('disabled', true);
  
          var domain = $('#domains').val().split("\n");
          var counter = 0;
  
          // an indicator to state when the button should be enabled again:
          var ajaxQueue = 0;
  
          //send ajax request for earse txt file (new request)
          $.ajax({
                  type: "GET",
                  url: "includes/ajax/ajax.php",
                  data: {new_request: ajaxQueue },
          });
  
          var Table = '&lt;table class="paginated table table-bordered table-striped table-responsive domain-table"&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;ID&lt;/th&gt;&lt;th&gt;Domain Name&lt;/th&gt;&lt;th&gt;.Com&lt;/th&gt;&lt;th&gt;.Net&lt;/th&gt;&lt;th&gt;.Org&lt;/th&gt;&lt;th&gt;.Ir&lt;/th&gt;&lt;th&gt;.Biz&lt;/th&gt;&lt;th&gt;.Info&lt;/th&gt;&lt;th&gt;.Us&lt;/th&gt;&lt;th&gt;.Name&lt;/th&gt;&lt;th&gt;.Pro&lt;/th&gt;&lt;th&gt;.Eu&lt;/th&gt;&lt;th&gt;.In&lt;/th&gt;&lt;th&gt;.Me&lt;/th&gt;&lt;th&gt;.Tv&lt;/th&gt;&lt;th&gt;.Cc&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;';
  
          // create the td elements, but do not perform AJAX requests there:
          $.each(domain, function (i, val) {
              counter++;
              Table += '&lt;tr&gt;&lt;td&gt;'+ counter +'&lt;/td&gt;&lt;td&gt;'+ val +'&lt;/td&gt;';
              $('input[type=checkbox]').each(function () {
                  if($(this).is(':checked')){
                      ajaxQueue++;
                      // if checkbox is checked make td element with specified values and a "load-me" class:
                      Table += '&lt;td class="load-me" data-domain="'+val+'" data-suffix="'+$(this).val()+'"&gt;&lt;small&gt;loading...&lt;/small&gt;&lt;/td&gt;';
                  }else{
                      Table += '&lt;td&gt;&lt;span class=text-muted&gt;&lt;i class="fa fa-minus"&gt;&lt;/i&gt;&lt;/span&gt;&lt;/td&gt;';
                  }
              });
              Table += '&lt;/tr&gt;';
          });
  
          // Replace HTML of the 'domain_tables' div and perform AJAX request for each td element with "load-me" class:
          $('#domain_tables').html(Table+'&lt;/tbody&gt;&lt;/table&gt;').find('td.load-me').each(function(){
              var td = $(this);
  
              $.ajax({
                  type: "POST",
                  url: "includes/ajax/ajax.php",
                  dataType: "json",
                  data: {domain: td.attr('data-domain'), suffix: td.attr('data-suffix')},
                  success: function (msg) {
                      // decrease ajaxQueue and if it's 0 enable button again:
                      ajaxQueue--;
                      if(ajaxQueue === 0){
                          btn.prop('disabled', false);
                      }
                      if(msg.suc == false){
                          td.html('&lt;span class=text-danger&gt;&lt;i class="fa fa-check"&gt;&lt;/i&gt;&lt;/span&gt;');
                      }else{
                          td.html('&lt;span class=text-success&gt;&lt;i class="fa fa-times"&gt;&lt;/i&gt;&lt;/span&gt;');
                      }
                  },
                  error: function (err) {
                      $('#domain_tables').html(err.error);
                  }
              });
          });
  
      // clear textarea and uncheck checkboxs
      $("#reset").click(function(){
          $('input[type=checkbox]').attr('checked', false);
          $('#domains').val('');
          $('#submit').prop('disabled', false);
      });
  
      // table paganation
      $('table.paginated').each(function() {
          var currentPage = 0;
          var numPerPage = 100;
          var $table = $(this);
          $table.bind('repaginate', function() {
              $table.find('tbody tr').hide().slice(currentPage * numPerPage, (currentPage + 1) * numPerPage).show();
          });
          $table.trigger('repaginate');
          var numRows = $table.find('tbody tr').length;
          var numPages = Math.ceil(numRows / numPerPage);
          var $pager = $('&lt;ul class="pager pagination"&gt;&lt;/ul&gt;');
          for (var page = 0; page &lt; numPages; page++) {
              $('&lt;li class="page-number"&gt;&lt;/li&gt;').text(page + 1).bind('click', {
                  newPage: page
              }, function(event) {
                  currentPage = event.data['newPage'];
                  $table.trigger('repaginate');
                  $(this).addClass('active').siblings().removeClass('active');
              }).appendTo($pager).addClass('clickable');
          }
          if(numRows &gt; 100 ){
              $pager.insertAfter($table).find('span.page-number:first').addClass('active');
          }
      });
  
      });
  
  
  
  }); 
  </code></pre>
  
  <p>PHP code (ajax.php):</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  if($_SERVER['REQUEST_METHOD']=='GET'){
      $new_request = $_GET['new_request'];
      // check new request flag for erase all data from txt file
      if(isset($new_request) &amp;&amp; $new_request == 0 ){
          $handle = fopen ("../textfile/data.txt", "w+");
          fclose($handle);
      }
  }
  if($_SERVER['REQUEST_METHOD']=='POST'){
      $domain = $_POST['domain'];
      $suffixes = $_POST['suffix'];
  
      $target = 'http://whois.apitruck.com/'.$domain.".".$suffixes;
      $getcontent = file_get_contents($target);
      $json = json_decode($getcontent);
      $status = $json-&gt;response-&gt;registered;
  
      if($status){
          die(json_encode(array('suc'=&gt;true)));
      } else {
          $file = '../textfile/data.txt';
          // Open the file to get existing content
          $current = file_get_contents($file);
          // Append a new person to the file
          $current .= $domain.".".$suffixes." | \n";
          // Write the contents back to the file
          file_put_contents($file, $current);
  
          die(json_encode(array('suc'=&gt;false)));
      }
  }
  ?&gt;
  </code></pre>