Skip to main content

Bug Tracker

Side navigation

#1598 closed bug (fixed)

Opened September 12, 2007 10:41AM UTC

Closed September 15, 2007 02:16AM UTC

Last modified September 20, 2007 03:32PM UTC

Execution of JavaScript code in AJAX response in IE and Safari

Reported by: diz Owned by:
Priority: major Milestone: 1.2.1
Component: core Version: 1.2
Keywords: domManip ajax javascript response Cc:
Blocked by: Blocking:


There's a problem for the execution of JavaScript mixed with HTML when loaded and integrated to the page through an AJAX.

Some of the <SCRIPT> elements don't get executed by Internet Explorer and Safari! This seems to be an error in the jQuery domManip() method which only looks for <SCRIPT> elements placed at the root of the loaded HTML.

The following AJAX response will work, the JavaScript will be executed, the paragraph will have two classes ('test' and 'ok'):

    <p class="test">test</p>
<script type="text/javascript" >

But the following JavaScript will NOT be executed, the paragraph will only have the class 'test':

    <p class="test">test</p>
    <script type="text/javascript" >

This worked in jQuery but doesn't work anymore for 1.1.4 or 1.2! Here is a minimized test case:

The JavaScript MUST be placed at the root of the DOM of the AJAX response, or it will not be executed in IE or in Safari. This is quite a problem in my case, where the AJAX response can be quite long and where the JavaScript is used to enhance the markup to make graphical enhancement (such as rounded corners). The whole response is within a <DIV> container, but the JavaScript should be placed immediately after each element which has to be decorated to avoid a styling flash.

Attachments (0)
Change History (3)

Changed September 12, 2007 01:32PM UTC by diz comment:1

Have also a look at the following ticket, which seems to be the same bug (without any AJAX):

Changed September 15, 2007 02:16AM UTC by john comment:2

resolution: → fixed
status: newclosed

Fixed in SVN rev [3296].

Changed September 20, 2007 03:32PM UTC by diz comment:3

By solving this bug, you created that one: