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: |
Description
Hello,
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'):
<div> <p class="test">test</p> </div> <script type="text/javascript" > $('.test').addClass('ok'); </script>
But the following JavaScript will NOT be executed, the paragraph will only have the class 'test':
<div> <p class="test">test</p> <script type="text/javascript" > $('.test').addClass('ok'); </script> </div>
This worked in jQuery 1.1.3.1 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=1.1.3.1
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 comment:1
Changed September 15, 2007 02:16AM UTC by comment:2
resolution: | → fixed |
---|---|
status: | new → closed |
Fixed in SVN rev [3296].
Changed September 20, 2007 03:32PM UTC by comment:3
By solving this bug, you created that one: http://dev.jquery.com/ticket/1698
Have also a look at the following ticket, which seems to be the same bug (without any AJAX):
http://dev.jquery.com/ticket/1594