Bug Tracker

Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#1598 closed bug (fixed)

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: http://wh.ysagoon.com/diz/tmp/jquery/ajax/?jquery=

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.

Change History (3)

comment:1 Changed 15 years ago by diz

Have also a look at the following ticket, which seems to be the same bug (without any AJAX): http://dev.jquery.com/ticket/1594

comment:2 Changed 15 years ago by john

Resolution: fixed
Status: newclosed

Fixed in SVN rev [3296].

comment:3 Changed 15 years ago by diz

By solving this bug, you created that one: http://dev.jquery.com/ticket/1698

Note: See TracTickets for help on using tickets.