title: Issue in Wordpress AJAX call: uncaught exception out of memory
body: <p>I am developing a custom theme for a client in Wordpress.  </p>
  
  <p>I'm doing an AJAX call that retrieves some data on document load, but while this works in Chrome, it redirects on the homepage in Firefox and IE and continue looping the AJAX request.</p>
  
  <p>Opening Firefox console, I can see this error:</p>
  
  <blockquote>
    <p>uncaught exception: out of memory</p>
  </blockquote>
  
  <p>And this warning:</p>
  
  <blockquote>
    <p>Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help <a href="http://xhr.spec.whatwg.org/" rel="nofollow">http://xhr.spec.whatwg.org/</a></p>
  </blockquote>
  
  <h3>Here's my ajax file</h3>
  
  <pre><code>$(document).ready(function(){
      var container = $('#single-path-content');
  
      var parentId = container.data('parent');
  
      if(container.length &gt; 0){
          ajax_main(parentId, 0);
      }
  });
  
  // fred_vars.ajaxurl is defined in functions.php a console.log of this variable is "http://fred.locl/wp-admin/admin-ajax.php"
  
  function ajax_main(parentId, start){
      $.ajax({
          url: fred_vars.ajaxurl,
          type: 'POST',
          data: 'action=fred_subpath&amp;parent_id='+parentId+'&amp;start='+start,
          beforeSend: function(){
              // SOME jQuery code
          },
          success: function(results){
              $('#single-path-content')
              .html(results);
  
              // SOME jQuery code
          },
          error: function(){
              alert('Error! Please reload');
          },
          complete: function(){
              // SOME jQuery code
          }
      });
  }
  </code></pre>
  
  <p>Just before rendering the homepage inside the page template the browser shows the alert in error function.</p>
  
  <h3>I've found some possible solution, but nothing that fits my scenario.</h3>