Answers.Body: <p>The next (post <a href="https://craftcms.com/changelog#build2767" rel="nofollow">2.5.2767</a> release) will no longer inject that code on AJAX requests.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-02T03:16:15.390Z
Answers.Text: Brad, possible this is showing up again with the latest 3.3.0.1 release?
Answers.UserDisplayName: Chase Giunta
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-28T23:22:57.907Z
Answers.Text: Shouldn't be: https://github.com/craftcms/cms/blob/develop/src/queue/Queue.php#L474-L477
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-11T20:50:06.970Z
Answers.Text: I'm seeing this at the bottom of certain frontend pages in 3.4.9 on pages that aren't performing any ajax requests.
Answers.UserDisplayName: cmal
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-26T15:04:10.213Z
Answers.Text: @cmal did you resolve this? I am seeing the same as you on 3.4.20
Answers.UserDisplayName: Sam
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-02T22:28:58.243Z
Answers.LastActivityDate: 2016-03-02T22:28:58.243Z
Answers.UserDisplayName: Brad Bell
Body: <p>I have created a route to retrieve some categories via AJAX. When the AJAX call returns the HTML a runPendingTask script is also returned with the HTML. How do I prevent this?</p>
  
  <pre><code>/*&lt;![CDATA[*/
  (function() {
      var XMLHttpFactories = [
          function() {
              return new XMLHttpRequest()
          },
          function() {
              return new ActiveXObject("Msxml2.XMLHTTP")
          },
          function() {
              return new ActiveXObject("Msxml3.XMLHTTP")
          },
          function() {
              return new ActiveXObject("Microsoft.XMLHTTP")
          }
      ];
      var req = false;
      for (var i = 0; i &lt; XMLHttpFactories.length; i++) {
          try {
              req = XMLHttpFactories[i]();
          } catch (e) {
              continue;
          }
          break;
      }
      if (!req) return;
      req.open('GET',
          "http:\/\/tfc.dev\/hollywood-road\/index.php\/actions\/tasks\/runPendingTasks",
          true);
      if (req.readyState == 4) return;
      req.send();
  })(); /*]]&gt;*/
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-03-02T22:38:26.950Z
Comments.Text: Per Brad's answer, closing this as a "bug report".
Comments.UserDisplayName: Lindsey D
Tags: <categories><routes><ajax>
Title: How do I prevent a runPendingTask script being included in returned HTML via ajax?
ThreadText: # How do I prevent a runPendingTask script being included in returned HTML via ajax?
  
  (Asked by: username_0 on 2016-03-02)
  
  I have created a route to retrieve some categories via AJAX. When the AJAX call returns the HTML a runPendingTask script is also returned with the HTML. How do I prevent this?
  
  ```
  /*<![CDATA[*/
  (function() {
      var XMLHttpFactories = [
          function() {
              return new XMLHttpRequest()
          },
          function() {
              return new ActiveXObject("Msxml2.XMLHTTP")
          },
          function() {
              return new ActiveXObject("Msxml3.XMLHTTP")
          },
          function() {
              return new ActiveXObject("Microsoft.XMLHTTP")
          }
      ];
      var req = false;
      for (var i = 0; i < XMLHttpFactories.length; i++) {
          try {
              req = XMLHttpFactories[i]();
          } catch (e) {
              continue;
          }
          break;
      }
      if (!req) return;
      req.open('GET',
          "http:\/\/tfc.dev\/hollywood-road\/index.php\/actions\/tasks\/runPendingTasks",
          true);
      if (req.readyState == 4) return;
      req.send();
  })(); /*]]>*/
  
  ```
  
  **Tags:** categories, routes, ajax
  
  > **Comments:**
  > **username_1**: Per username_2's answer, closing this as a "bug report".  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2016-03-02. Score: 1
  
  The next (post [2.5.2767](https://craftcms.com/changelog#build2767) release) will no longer inject that code on AJAX requests.
  
  > **Comments:**
  > **username_3**: username_2, possible this is showing up again with the latest 3.3.0.1 release?  
  > **username_2**: Shouldn't be: https://github.com/craftcms/cms/blob/develop/src/queue/Queue.php#L474-L477  
  > **username_4**: I'm seeing this at the bottom of certain frontend pages in 3.4.9 on pages that aren't performing any ajax requests.  
  > **username_5**: @username_4 did you resolve this? I am seeing the same as you on 3.4.20  
  
  ---
  
  