<script type="text/javascript" id="js-nexaas-async-collector-<%= unique_id %>">
  var requestContent = function() {
    $.ajax({
      url: '<%= nexaas_async_collector.async_resource_path(collect_id) %>',
      dataType: 'script',
      data: { unique_id: '<%= unique_id %>' }
    })
  }

  window.nexaas_async_interval = setInterval(requestContent, 3000);
</script>

<%= render partial: "nexaas/async/collector/async_resource/loading", locals: { unique_id: unique_id } %>

<script type="text/javascript" id="js-nexaas-async-collector-<%= unique_id %>">
  if (!!window.nexaas_async_interval)
    clearInterval(window.nexaas_async_interval);

  var requestContent = function() {
    $.ajax({
      url: '<%= nexaas_async_collector.async_resource_path(collect_id) %>',
      dataType: 'script',
      data: { unique_id: '<%= unique_id %>' }
    })
  }

  window.nexaas_async_interval = setInterval(requestContent, 3000);
</script>

<%= render partial: "nexaas/async/collector/async_resource/loading", locals: { unique_id: unique_id } %>

Clear interval when rendering loading and the interval already exists
Clear interval when rendering loading and the interval already exists
