Skip to main content

Bug Tracker

Side navigation

#407 closed bug (fixed)

Opened November 17, 2006 04:55PM UTC

Closed December 22, 2006 09:13AM UTC

getScript and Safari

Reported by: aercolino at yahoo.c Owned by:
Priority: major Milestone: 1.1a
Component: ajax Version: 1.1a
Keywords: Cc:
Blocked by: Blocking:

While developing the PunchCard widget I've found a problem with getScript in


If you are interested in helping me, I've isolated the issue here:

Attachments (3)
  • ajax.js.2.patch (1.6 KB) - added by pmclanahan November 20, 2006 07:13PM UTC.

    Patch file from my post on 11-20-2006

  • ajax.js.patch (1.6 KB) - added by pmclanahan November 20, 2006 07:12PM UTC.

    Patch file from my post on 11-20-2006

  • ajax.js.patch.txt (1.6 KB) - added by pmclanahan November 20, 2006 07:13PM UTC.

    Patch file from my post on 11-20-2006

Change History (10)

Changed November 17, 2006 07:01PM UTC by anonymous comment:1

You must not use either of the following two methods (they're synonymous) when using getScript when defining functions in the scripts to be loaded.

function myFunc(){}

var myFunc = function(){}

However, if you define functions like this:

myFunc = function(){} // note the lack of "var"

Then it will be available and work fine. I've found no fix for this

in jQuery source. For now we just have to be careful of the scripts we

load in.

You can also keep using the first method above and just define the

variable in the global scope earlier in the script file like so:

myFunc = myOtherFunc = {};

function myFunc(){}


This was tested against SVN jQuery and IE7.

Changed November 18, 2006 09:49PM UTC by aercolino@ya comment:2

Please refer to the page for testing the general solution based on a script by Jeff Watkins. I provide a link to Jeff's post documenting its findings.

I think that Jeff's installScript function for evaluating a script in the global scope should be added to the core of jQuery, with the signature "void jQuery.eval( String script )" and every call in jQuery to window.eval should be replaced by a call to jQuery.eval

execScript seems to be available since IE4.x at least (maybe before too)

execScript gets a second optional argument for the language: it defaults to jscript

Changed November 20, 2006 07:23PM UTC by pmclanahan comment:3

Update: I checked the test suite in Safari 1.3.2 and some stuff is broken: "9 tests of 283 failed." The only error in ajax.js however was serialize, and all of the failures existed prior to applying my patch. In other words, it fails in Safari in exactly the same way.

Another note: this last patch I posted from today (11/20/2006) is not in addition to the one posted previously, it is meant to be instead of.


Changed November 20, 2006 08:40PM UTC by joern comment:4

Thanks Paul. I just commited your patch and modified one test, it runs fine on FF1.5, IE6, IE7 and Opera 9. Though I'm not sure if the eval/global context stuff is really covered.

Unfortuatenetely I can't declare this bug is fixed... stupid spam :/

Changed November 21, 2006 09:13AM UTC by joern comment:5

This stuff should be extracted as $.eval:

  setTimeout(data, 0)

And then replace that call within httpData and evalScripts.

API change scheduled for 1.1.

Changed November 21, 2006 09:58AM UTC by joern comment:6

Using setTimeout causes the eval to run asynchrounosly, which is ugly. Using window, data) works fine together with window.execScript. According to my tests it runs for FF1.5, IE6, IE7 and Opera 9.

Changed November 21, 2006 03:28PM UTC by andrea comment:7

I think that Jeff sais something about Safari support of, data)

Changed November 22, 2006 11:03PM UTC by joern comment:8

Latest version for $.eval (or rather, $.globalEval)

jQuery.globalEval = function(data){
 if(window.execScript) // msie
 else if(jQuery.browser.safari) // safari
 else // all others window, data );
} or self.eval won't work either on Safari. Looks like we must live with the timeout, but that must be documented.

Changed December 02, 2006 01:25PM UTC by joern comment:9

summary: getScript and IE7getScript and Safari

Fixed for IE7, but won't fix for Safari. If anyone finds a more reliable workaround for Safari...

Changed December 22, 2006 09:13AM UTC by joern comment:10

resolution: → fixed
status: newclosed

No way to fix it for safari.