Skip to main content

Bug Tracker

Side navigation

#858 closed bug (duplicate)

Opened January 22, 2007 03:24AM UTC

Closed March 24, 2007 03:42AM UTC

evalScripts() execute javascript twice with inline script from ajax data in Firefox

Reported by: Lasiaf Owned by:
Priority: minor Milestone: 1.1.3
Component: ajax Version: 1.1
Keywords: evalscripts ajax script firefox execute Cc:
Blocked by: Blocking:
Description

Whe I try to load an external page with an inline script, firefox evaluates the script but IE dont.

so my solution is put evalScripts() at the appended data, the it works in IE but it executes twice in firefox.

Sample Code

		$.post("getsomething.php",{test:1},
			function(data){
				$("#mainPane").append(data).evalScripts();
			}
		)

getsomething.php

IMPORTANT DATA TO BE APPENDED
<script> 
alert("Hello World"); 
$("#txt1").val("NEW VAR DATA");
</script>


Whats happening is Firefox is evaluating the new appended data then evaluates it again using evalScripts()

is there a way to call evalScripts in $.html $.append when I use it in IE and if its firefox not to call evalScripts()

Attachments (0)
Change History (4)

Changed January 23, 2007 05:34PM UTC by joern comment:1

description: Whe I try to load an external page with an inline script, firefox evaluates the script but IE dont.\ so my solution is put evalScripts() at the appended data, the it works in IE but it executes twice in firefox.\ Sample Code\ $.post("getsomething.php",{test:1},\ function(data){\ $("#mainPane").append(data).evalScripts();\ }\ )\ getsomething.php\ IMPORTANT DATA TO BE APPENDED\ <script> \ alert("Hello World"); \ $("#txt1").val("NEW VAR DATA");\ </script>\ ---\ \ Whats happening is Firefox is evaluating the new appended data then evaluates it again using evalScripts()\ \ is there a way to call evalScripts in $.html $.append when I use it in IE and if its firefox not to call evalScripts()Whe I try to load an external page with an inline script, firefox evaluates the script but IE dont.\ so my solution is put evalScripts() at the appended data, the it works in IE but it executes twice in firefox.\ Sample Code\ {{{\ $.post("getsomething.php",{test:1},\ function(data){\ $("#mainPane").append(data).evalScripts();\ }\ )\ }}}\ getsomething.php\ {{{\ IMPORTANT DATA TO BE APPENDED\ <script> \ alert("Hello World"); \ $("#txt1").val("NEW VAR DATA");\ </script>\ }}}\ ---\ \ Whats happening is Firefox is evaluating the new appended data then evaluates it again using evalScripts()\ \ is there a way to call evalScripts in $.html $.append when I use it in IE and if its firefox not to call evalScripts()
milestone: → 1.1
version: → 1.1

A rather ugly workaround would be a manuel append using html. It's still unclear why append evaluate scripts at all, that behaviour was introduced in some of the later jQuery versions.

Changed January 24, 2007 02:38AM UTC by Lasiaf comment:2

So if I use the old versions it should just work fine?

Changed March 08, 2007 06:35PM UTC by brandon comment:3

This is related to #975

Changed March 24, 2007 03:42AM UTC by john comment:4

resolution: → duplicate
status: newclosed

We're going to discuss this bug in #975. Closing this ticket.