<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>

CC BY-SA 4.0
2019-09-02T03:16:15.390Z
Brad, possible this is showing up again with the latest 3.3.0.1 release?
Chase Giunta
CC BY-SA 4.0
2020-01-28T23:22:57.907Z
Shouldn't be: https://github.com/craftcms/cms/blob/develop/src/queue/Queue.php#L474-L477
Brad Bell
CC BY-SA 4.0
2020-03-11T20:50:06.970Z
I'm seeing this at the bottom of certain frontend pages in 3.4.9 on pages that aren't performing any ajax requests.
cmal
CC BY-SA 4.0
2020-06-26T15:04:10.213Z
@cmal did you resolve this? I am seeing the same as you on 3.4.20
Sam
CC BY-SA 3.0
2016-03-02T22:28:58.243Z
2016-03-02T22:28:58.243Z
Brad Bell
<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>

CC BY-SA 3.0
2016-03-02T22:38:26.950Z
Per Brad's answer, closing this as a "bug report".
Lindsey D
<categories><routes><ajax>
How do I prevent a runPendingTask script being included in returned HTML via ajax?
# 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?
/**/
(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 Brad'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**: Brad, 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  

---

