Re: [jQuery] getScript error

2006-11-24 Thread Andrea Ercolino


Michael Geary wrote:
> 
>require( 'test.js', function() {
>   // This code runs when the script is loaded
>});
> 

jQuery already had the $.getScript function to use the same way as the
require in your example above. And this is the reason we are trying to have
it work properly in this thread.
-- 
View this message in context: 
http://www.nabble.com/getScript-error-tf2652417.html#a7519037
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-23 Thread Michael Geary
> > Why not use document.createElement("script") !?

> Because we want jQuery to wait until the script is loaded and 
> evaluated, so it's possible to do something upon completion, 
> like continuing the normal flow of the program. This is 
> necessary for example for writing a require like the one in PHP.

You can't do that, and you wouldn't want to if you could. JavaScript doesn't
work that way. If you were successful in getting JavaScript to wait until a
script is loaded, the entire browser would be locked up in the meantime.

What you *could* do is something like this:

   require( script, completion );

e.g.

   require( 'test.js', function() {
  // This code runs when the script is loaded
   });

-Mike


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-23 Thread 沈志川 (Benx)

If so, you can not override jQuery.getScript function.

But my test result is, IE6 and FF2 would wait to finish downloading the
script
and continue the program.


jQuery.getScript = function (src, callback) {
var js = document.createElement('SCRIPT');
js.type = 'text/javascript';
js.src = src;
js.defer = true;
document.body.appendChild(js);  // IE6 and FF2 would wait to

finish downloading the script (NOT async)
 if(callback) callback(js.text || js.textContent || js.innerHTML ||
"");  // call the callback function

}





On 11/24/06, Andrea Ercolino <[EMAIL PROTECTED]> wrote:




沈志川 (Benx) wrote:
>
> Why not use document.createElement("script") !?
>

Because we want jQuery to wait until the script is loaded and evaluated,
so
it's possible to do something upon completion, like continuing the normal
flow of the program. This is necessary for example for writing a require
like the one in PHP.

--
View this message in context:
http://www.nabble.com/getScript-error-tf2652417.html#a7514393
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/





--
Best regards,
沈志川 (Benx)
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-23 Thread Andrea Ercolino


Jörn Zaefferer wrote:
> 
> Looks good for me. 
> 

I have browsed dojo and prototype today, but they seem to do nothing special
for eval, ie: I think that they share the same problem, but are unaware of
it.

-- 
View this message in context: 
http://www.nabble.com/getScript-error-tf2652417.html#a7515295
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-23 Thread Andrea Ercolino


沈志川 (Benx) wrote:
> 
> Why not use document.createElement("script") !?
> 

Because we want jQuery to wait until the script is loaded and evaluated, so
it's possible to do something upon completion, like continuing the normal
flow of the program. This is necessary for example for writing a require
like the one in PHP.
 
-- 
View this message in context: 
http://www.nabble.com/getScript-error-tf2652417.html#a7514393
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-23 Thread Klaus Hartl
沈志川 (Benx) schrieb:
> Why not use document.createElement("script") !?
> 
> Here is my solution and work well in IE6 and FF2
> 
> // replace the call for eval.call(window, script)
> jQuery.evalJS = function (script) {
> var js = document.createElement('SCRIPT');
> js.type = 'text/javascript';
> js.text = script;
> document.body.appendChild(js);
> };
> 
> // @override
> jQuery.getScript = function (src, callback) {
> var js = document.createElement('SCRIPT');
> js.type = 'text/javascript';
> js.src = src;
> js.defer = true;
> document.body.appendChild(js);
> }

I haven't followed sorrowly, so I don't know if that would be the 
solution to the problem.

I only know that support for adding dynamically created script elements 
has been added in Safari not until version 2.01, so this isn't really an 
option I assume.

http://webkit.org/blog/?p=26

-- 
Klaus

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-23 Thread 沈志川 (Benx)

Why not use document.createElement("script") !?

Here is my solution and work well in IE6 and FF2

// replace the call for eval.call(window, script)
jQuery.evalJS = function (script) {
   var js = document.createElement('SCRIPT');
   js.type = 'text/javascript';
   js.text = script;
   document.body.appendChild(js);
};

// @override
jQuery.getScript = function (src, callback) {
   var js = document.createElement('SCRIPT');
   js.type = 'text/javascript';
   js.src = src;
   js.defer = true;
   document.body.appendChild(js);
}



On 11/23/06, Karl Rudd <[EMAIL PROTECTED]> wrote:


I can confirm that (window.execScript || self.eval)(script) does NOT
work in Safari 2.0.4 (419.3). It also does not work in Opera 9.

The test harness I used was:

   var local = "test";
   (function() {
   var s = 'function blah(){alert("from blah()");};
local="changed";';
   (window.execScript || self.eval)( s );  // IE, Mozilla
   //eval.call( window, s ); // Opera, Mozilla
   // window.setTimeout(s,0); // blah() fails in all
   })();
   alert(local);
   blah();

Karl Rudd

On 11/23/06, Paul McLanahan <[EMAIL PROTECTED]> wrote:
> That's a cool fix. I really like your syntax.  However, Safari still
> won't eval that globally either using self.eval or window.eval.  That
> is as tested on Safari 1.3, I don't have easy access to 2.0.  I can
> try it there later though.
>
> On 11/22/06, Francisco Brito <[EMAIL PROTECTED]> wrote:
> > I don't have access to safari right now, but perhaps this might work:
> >
> > self.eval(); // or window.self.eval if you can see the performance
change
> >
> > I remember having a similar problem with firefox a bit ago using
> > window.eval() and that fixed it. I ended up with:
> >
> > (window.execScript || self.eval)(script);
> >
> > I have a fresh post about this:
> >
http://nullisnull.blogspot.com/2006/11/executing-scripts-with-xmlhttprequest.html
> > I'm curious to see if it works with Safari.
> >
> > --
> > Brito
> >
> >
> >
> > On 11/22/06, Paul McLanahan <[EMAIL PROTECTED]> wrote:
> > > I just checked eval.call(window,data) on Safari 2.0.4 and it did NOT
> > > work.  The function was available immediately, but only in the scope
> > > of the httpData function. And with window.setTimeout it was
available
> > > globally, but not immediately inside of httpData
> > >
> > > 
> > >
> > > Example...
> > >
> > > external file
> > > 
> > > function gsTest(){alert("Success!!");}
> > > 
> > >
> > > inside of $.httpData()
> > > 
> > > window.execScript?window.execScript(data):eval.call( window, data );
> > > gsTest();
> > > 
> > >
> > > In Safari 1.3 or 2.0 the above will alert "Success!!", however,
> > > clicking on test in the document
> > > does not work.
> > >
> > > inside of $.httpData()
> > > 
> > >
> > window.execScript?window.execScript(data):jQuery.browser.safari
?window.setTimeout(data,0):eval.call(
> > > window, data );
> > > gsTest();
> > > 
> > >
> > > In Safari 1.3 or 2.0 the above will NOT alert "Success!!"
immediately.
> > > It will throw an error. But, clicking on a link like  > > onclick="gsTest()">test in the document will work.
> > >
> > > Anyone got any ideas? I'm fresh out. If we can't solve this, then I
> > > suggest we keep the window.setTimeout in there for Safari since I
> > > believe that global availability will be the feature most often used
> > > and the 10ms problem will be encountered very rarely.  I completely
> > > agree with Jörn that it should be documented in the code of the
> > > function.
> > >
> > > On 11/22/06, Jörn Zaefferer <[EMAIL PROTECTED]> wrote:
> > > > Paul McLanahan schrieb:
> > > > > jQuery.gEval = function(data){
> > > > >   if(window.execScript) // msie
> > > > >   window.execScript(data);
> > > > >   else if(jQuery.browser.safari) // safari
> > > > >   window.setTimeout (data,0);
> > > > >   else // all others
> > > > >   eval.call( window, data );
> > > > > }
> > > > >
> > > > > What do you guys think? Works in all my tests so far, but again,
I
> > > > > don't have SVN access here so I'm SOL as far as the sweet
new test
> > > > > suite goes.
> > > > >
> > > > Looks good for me. We should note somewhere that the evaluation is
> > > > asynchronous for Safari. If anyone actually happens to stumble
about
> > > > that problem, it's nice to have it documented.
> > > >
> > > > Could you please check Safari 2.x? It would be nice to use
eval.call()
> > > > if possible...
> > > >
> > > > --
> > > > Jörn Zaefferer
> > > >
> > > > http://bassistance.de
> > > >
> > > >
> > > > ___
> > > > jQuery mailing list
> > > > discuss@jquery.com
> > > > http://jquery.com/discuss/
> > > >
> > >
> > > __

Re: [jQuery] getScript error

2006-11-23 Thread Andrea Ercolino


Karl Rudd wrote:
> 
>  // window.setTimeout(s,0); // blah() fails in all
> Karl Rudd
> 

This is very surprising. I tested the setTimeout before posting Jeff's
installScript to this thread, and I found that it worked. But my test was
inappropriate, because I wanted it to succeed with my getScript issue, while
you wanted it to fail in general and your attitude is much better than mine,
for testing something.

So this is just to confirm that your claiming about setTimeout is correct.
Here are the results of my new testing session, using a case very similar to
yours:

The setTimeout works never in Opera, and some times does, other does not in
Firefox. 

Here are the details:

fresh cache
% is subjective

IE + head call: 1st alert: good - 2nd alert: good
IE + body call: 1st alert: good - 2nd alert: good

FF + head call + eval.call: 1st alert: good - 2nd alert: good
FF + body call + eval.call: 1st alert: good - 2nd alert: good

Op + head call + eval.call: 1st alert: good - 2nd alert: good
Op + body call + eval.call: 1st alert: good - 2nd alert: good

FF + head call + setTimeout + go:   1st alert: bad  - 2nd alert: 90% bad
FF + head call + setTimeout + refresh:  1st alert: bad  - 2nd alert: 60% bad

FF + body call + setTimeout + go:   1st alert: bad  - 2nd alert: 60% bad
FF + body call + setTimeout + refresh:  1st alert: bad  - 2nd alert: 60% bad

Op + head call + setTimeout:1st alert: bad  - 2nd alert: bad
Op + body call + setTimeout:1st alert: bad  - 2nd alert: bad




And here is the script used for testing:

function jQuery_eval( script ) {
if (!script)
return;
if (window.execScript)
window.execScript( script );
else {
eval.call( window, script );
//  window.setTimeout( script, 0 );
}
}

var global = "not changed";

function hereScript( fn ) {
var re = new RegExp( "function\\s*\\(\\s*\\)\\s*\\{((?:.|\\n)*)\\}", 
"g" );
return re.exec( fn )[1];
}

var script = hereScript( function() {
//-
function blah2() {
alert( "hello from blah2()" );
}
global = "changed";
//-
} );

//alert( script );
function test() {
jQuery_eval( script );
alert( global );
try {
blah2();
}
catch( e ) {
alert( e );
}
}

//test();

-- 
View this message in context: 
http://www.nabble.com/getScript-error-tf2652417.html#a7508366
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-22 Thread Karl Rudd
I can confirm that (window.execScript || self.eval)(script) does NOT
work in Safari 2.0.4 (419.3). It also does not work in Opera 9.

The test harness I used was:

   var local = "test";
   (function() {
   var s = 'function blah(){alert("from blah()");};
local="changed";';
   (window.execScript || self.eval)( s );  // IE, Mozilla
   //eval.call( window, s ); // Opera, Mozilla
   // window.setTimeout(s,0); // blah() fails in all
   })();
   alert(local);
   blah();

Karl Rudd

On 11/23/06, Paul McLanahan <[EMAIL PROTECTED]> wrote:
> That's a cool fix. I really like your syntax.  However, Safari still
> won't eval that globally either using self.eval or window.eval.  That
> is as tested on Safari 1.3, I don't have easy access to 2.0.  I can
> try it there later though.
>
> On 11/22/06, Francisco Brito <[EMAIL PROTECTED]> wrote:
> > I don't have access to safari right now, but perhaps this might work:
> >
> > self.eval(); // or window.self.eval if you can see the performance change
> >
> > I remember having a similar problem with firefox a bit ago using
> > window.eval() and that fixed it. I ended up with:
> >
> > (window.execScript || self.eval)(script);
> >
> > I have a fresh post about this:
> > http://nullisnull.blogspot.com/2006/11/executing-scripts-with-xmlhttprequest.html
> > I'm curious to see if it works with Safari.
> >
> > --
> > Brito
> >
> >
> >
> > On 11/22/06, Paul McLanahan <[EMAIL PROTECTED]> wrote:
> > > I just checked eval.call(window,data) on Safari 2.0.4 and it did NOT
> > > work.  The function was available immediately, but only in the scope
> > > of the httpData function. And with window.setTimeout it was available
> > > globally, but not immediately inside of httpData
> > >
> > > 
> > >
> > > Example...
> > >
> > > external file
> > > 
> > > function gsTest(){alert("Success!!");}
> > > 
> > >
> > > inside of $.httpData()
> > > 
> > > window.execScript?window.execScript(data):eval.call( window, data );
> > > gsTest();
> > > 
> > >
> > > In Safari 1.3 or 2.0 the above will alert "Success!!", however,
> > > clicking on test in the document
> > > does not work.
> > >
> > > inside of $.httpData()
> > > 
> > >
> > window.execScript?window.execScript(data):jQuery.browser.safari?window.setTimeout(data,0):eval.call(
> > > window, data );
> > > gsTest();
> > > 
> > >
> > > In Safari 1.3 or 2.0 the above will NOT alert "Success!!" immediately.
> > > It will throw an error. But, clicking on a link like  > > onclick="gsTest()">test in the document will work.
> > >
> > > Anyone got any ideas? I'm fresh out. If we can't solve this, then I
> > > suggest we keep the window.setTimeout in there for Safari since I
> > > believe that global availability will be the feature most often used
> > > and the 10ms problem will be encountered very rarely.  I completely
> > > agree with Jörn that it should be documented in the code of the
> > > function.
> > >
> > > On 11/22/06, Jörn Zaefferer <[EMAIL PROTECTED]> wrote:
> > > > Paul McLanahan schrieb:
> > > > > jQuery.gEval = function(data){
> > > > >   if(window.execScript) // msie
> > > > >   window.execScript(data);
> > > > >   else if(jQuery.browser.safari) // safari
> > > > >   window.setTimeout (data,0);
> > > > >   else // all others
> > > > >   eval.call( window, data );
> > > > > }
> > > > >
> > > > > What do you guys think? Works in all my tests so far, but again, I
> > > > > don't have SVN access here so I'm SOL as far as the sweet new test
> > > > > suite goes.
> > > > >
> > > > Looks good for me. We should note somewhere that the evaluation is
> > > > asynchronous for Safari. If anyone actually happens to stumble about
> > > > that problem, it's nice to have it documented.
> > > >
> > > > Could you please check Safari 2.x? It would be nice to use eval.call()
> > > > if possible...
> > > >
> > > > --
> > > > Jörn Zaefferer
> > > >
> > > > http://bassistance.de
> > > >
> > > >
> > > > ___
> > > > jQuery mailing list
> > > > discuss@jquery.com
> > > > http://jquery.com/discuss/
> > > >
> > >
> > > ___
> > > jQuery mailing list
> > > discuss@jquery.com
> > > http://jquery.com/discuss/
> > >
> >
> >
> >
> > --
> > Francisco Brito
> >
> > software:http://nullisnull.blogspot.com
> > photography:
> > http://www.flickr.com/photos/darkgoyle
> > everything else:   http://brito.mindsay.com
> > ___
> > jQuery mailing list
> > discuss@jquery.com
> > http://jquery.com/discuss/
> >
> >
> >
>
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>
___
jQ

Re: [jQuery] getScript error

2006-11-22 Thread Paul McLanahan
That's a cool fix. I really like your syntax.  However, Safari still
won't eval that globally either using self.eval or window.eval.  That
is as tested on Safari 1.3, I don't have easy access to 2.0.  I can
try it there later though.

On 11/22/06, Francisco Brito <[EMAIL PROTECTED]> wrote:
> I don't have access to safari right now, but perhaps this might work:
>
> self.eval(); // or window.self.eval if you can see the performance change
>
> I remember having a similar problem with firefox a bit ago using
> window.eval() and that fixed it. I ended up with:
>
> (window.execScript || self.eval)(script);
>
> I have a fresh post about this:
> http://nullisnull.blogspot.com/2006/11/executing-scripts-with-xmlhttprequest.html
> I'm curious to see if it works with Safari.
>
> --
> Brito
>
>
>
> On 11/22/06, Paul McLanahan <[EMAIL PROTECTED]> wrote:
> > I just checked eval.call(window,data) on Safari 2.0.4 and it did NOT
> > work.  The function was available immediately, but only in the scope
> > of the httpData function. And with window.setTimeout it was available
> > globally, but not immediately inside of httpData
> >
> > 
> >
> > Example...
> >
> > external file
> > 
> > function gsTest(){alert("Success!!");}
> > 
> >
> > inside of $.httpData()
> > 
> > window.execScript?window.execScript(data):eval.call( window, data );
> > gsTest();
> > 
> >
> > In Safari 1.3 or 2.0 the above will alert "Success!!", however,
> > clicking on test in the document
> > does not work.
> >
> > inside of $.httpData()
> > 
> >
> window.execScript?window.execScript(data):jQuery.browser.safari?window.setTimeout(data,0):eval.call(
> > window, data );
> > gsTest();
> > 
> >
> > In Safari 1.3 or 2.0 the above will NOT alert "Success!!" immediately.
> > It will throw an error. But, clicking on a link like  > onclick="gsTest()">test in the document will work.
> >
> > Anyone got any ideas? I'm fresh out. If we can't solve this, then I
> > suggest we keep the window.setTimeout in there for Safari since I
> > believe that global availability will be the feature most often used
> > and the 10ms problem will be encountered very rarely.  I completely
> > agree with Jörn that it should be documented in the code of the
> > function.
> >
> > On 11/22/06, Jörn Zaefferer <[EMAIL PROTECTED]> wrote:
> > > Paul McLanahan schrieb:
> > > > jQuery.gEval = function(data){
> > > >   if(window.execScript) // msie
> > > >   window.execScript(data);
> > > >   else if(jQuery.browser.safari) // safari
> > > >   window.setTimeout (data,0);
> > > >   else // all others
> > > >   eval.call( window, data );
> > > > }
> > > >
> > > > What do you guys think? Works in all my tests so far, but again, I
> > > > don't have SVN access here so I'm SOL as far as the sweet new test
> > > > suite goes.
> > > >
> > > Looks good for me. We should note somewhere that the evaluation is
> > > asynchronous for Safari. If anyone actually happens to stumble about
> > > that problem, it's nice to have it documented.
> > >
> > > Could you please check Safari 2.x? It would be nice to use eval.call()
> > > if possible...
> > >
> > > --
> > > Jörn Zaefferer
> > >
> > > http://bassistance.de
> > >
> > >
> > > ___
> > > jQuery mailing list
> > > discuss@jquery.com
> > > http://jquery.com/discuss/
> > >
> >
> > ___
> > jQuery mailing list
> > discuss@jquery.com
> > http://jquery.com/discuss/
> >
>
>
>
> --
> Francisco Brito
>
> software:http://nullisnull.blogspot.com
> photography:
> http://www.flickr.com/photos/darkgoyle
> everything else:   http://brito.mindsay.com
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>
>
>

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-22 Thread Francisco Brito

I don't have access to safari right now, but perhaps this might work:

self.eval(); // or window.self.eval if you can see the performance change

I remember having a similar problem with firefox a bit ago using window.eval()
and that fixed it. I ended up with:

(window.execScript || self.eval)(script);

I have a fresh post about this:
http://nullisnull.blogspot.com/2006/11/executing-scripts-with-xmlhttprequest.html
I'm curious to see if it works with Safari.

--
Brito


On 11/22/06, Paul McLanahan <[EMAIL PROTECTED]> wrote:


I just checked eval.call(window,data) on Safari 2.0.4 and it did NOT
work.  The function was available immediately, but only in the scope
of the httpData function. And with window.setTimeout it was available
globally, but not immediately inside of httpData



Example...

external file

function gsTest(){alert("Success!!");}


inside of $.httpData()

window.execScript?window.execScript(data):eval.call( window, data );
gsTest();


In Safari 1.3 or 2.0 the above will alert "Success!!", however,
clicking on test in the document
does not work.

inside of $.httpData()

window.execScript?window.execScript(data):jQuery.browser.safari
?window.setTimeout(data,0):eval.call(
window, data );
gsTest();


In Safari 1.3 or 2.0 the above will NOT alert "Success!!" immediately.
It will throw an error. But, clicking on a link like test in the document will work.

Anyone got any ideas? I'm fresh out. If we can't solve this, then I
suggest we keep the window.setTimeout in there for Safari since I
believe that global availability will be the feature most often used
and the 10ms problem will be encountered very rarely.  I completely
agree with Jörn that it should be documented in the code of the
function.

On 11/22/06, Jörn Zaefferer <[EMAIL PROTECTED]> wrote:
> Paul McLanahan schrieb:
> > jQuery.gEval = function(data){
> >   if(window.execScript) // msie
> >   window.execScript(data);
> >   else if(jQuery.browser.safari) // safari
> >   window.setTimeout(data,0);
> >   else // all others
> >   eval.call( window, data );
> > }
> >
> > What do you guys think? Works in all my tests so far, but again, I
> > don't have SVN access here so I'm SOL as far as the sweet new test
> > suite goes.
> >
> Looks good for me. We should note somewhere that the evaluation is
> asynchronous for Safari. If anyone actually happens to stumble about
> that problem, it's nice to have it documented.
>
> Could you please check Safari 2.x? It would be nice to use eval.call()
> if possible...
>
> --
> Jörn Zaefferer
>
> http://bassistance.de
>
>
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/





--
Francisco Brito

software:http://nullisnull.blogspot.com
photography:   http://www.flickr.com/photos/darkgoyle
everything else:   http://brito.mindsay.com
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-22 Thread Paul McLanahan
I just checked eval.call(window,data) on Safari 2.0.4 and it did NOT
work.  The function was available immediately, but only in the scope
of the httpData function. And with window.setTimeout it was available
globally, but not immediately inside of httpData



Example...

external file

function gsTest(){alert("Success!!");}


inside of $.httpData()

window.execScript?window.execScript(data):eval.call( window, data );
gsTest();


In Safari 1.3 or 2.0 the above will alert "Success!!", however,
clicking on test in the document
does not work.

inside of $.httpData()

window.execScript?window.execScript(data):jQuery.browser.safari?window.setTimeout(data,0):eval.call(
window, data );
gsTest();


In Safari 1.3 or 2.0 the above will NOT alert "Success!!" immediately.
It will throw an error. But, clicking on a link like test in the document will work.

Anyone got any ideas? I'm fresh out. If we can't solve this, then I
suggest we keep the window.setTimeout in there for Safari since I
believe that global availability will be the feature most often used
and the 10ms problem will be encountered very rarely.  I completely
agree with Jörn that it should be documented in the code of the
function.

On 11/22/06, Jörn Zaefferer <[EMAIL PROTECTED]> wrote:
> Paul McLanahan schrieb:
> > jQuery.gEval = function(data){
> >   if(window.execScript) // msie
> >   window.execScript(data);
> >   else if(jQuery.browser.safari) // safari
> >   window.setTimeout(data,0);
> >   else // all others
> >   eval.call( window, data );
> > }
> >
> > What do you guys think? Works in all my tests so far, but again, I
> > don't have SVN access here so I'm SOL as far as the sweet new test
> > suite goes.
> >
> Looks good for me. We should note somewhere that the evaluation is
> asynchronous for Safari. If anyone actually happens to stumble about
> that problem, it's nice to have it documented.
>
> Could you please check Safari 2.x? It would be nice to use eval.call()
> if possible...
>
> --
> Jörn Zaefferer
>
> http://bassistance.de
>
>
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-22 Thread Jörn Zaefferer
Paul McLanahan schrieb:
> jQuery.gEval = function(data){
>   if(window.execScript) // msie
>   window.execScript(data);
>   else if(jQuery.browser.safari) // safari
>   window.setTimeout(data,0);
>   else // all others
>   eval.call( window, data );
> }
>
> What do you guys think? Works in all my tests so far, but again, I
> don't have SVN access here so I'm SOL as far as the sweet new test
> suite goes.
>   
Looks good for me. We should note somewhere that the evaluation is 
asynchronous for Safari. If anyone actually happens to stumble about 
that problem, it's nice to have it documented.

Could you please check Safari 2.x? It would be nice to use eval.call() 
if possible...

-- 
Jörn Zaefferer

http://bassistance.de


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-22 Thread Paul McLanahan
Ok... I was able to confirm that, at least for the version of Safari I
have (1.3.2 on OSX.3.9), the eval.call(window,data) attempt at global
scope eval does not work.  I got some strange "Object (result of
expression testFunction) does not allow calls" error, where
"testFunction" was the function I was trying to define from an
external script file.  So I fixed it and I have what I believe to be
the final version of $.eval (or $.gEval as I'd prefer it).

jQuery.gEval = function(data){

window.execScript?window.execScript(data):jQuery.browser.safari?window.setTimeout(data,0):eval.call(
window, data );
}

or for readability's sake:

jQuery.gEval = function(data){
if(window.execScript) // msie
window.execScript(data);
else if(jQuery.browser.safari) // safari
window.setTimeout(data,0);
else // all others
eval.call( window, data );
}

What do you guys think? Works in all my tests so far, but again, I
don't have SVN access here so I'm SOL as far as the sweet new test
suite goes.

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-22 Thread Jörn Zaefferer
> Jorn: I'm not sure which versions of Safari are affected.  I'll do
> some more research and get back to you.  Hopefully it's fixed in
> recent versions and we won't have to worry about it.  I don't have SVN
> access here at work, or I'd update my working copy and run the test
> suite on safari 1.3.2 that I have here.

This should be the latest revision:

http://jquery.bassistance.de/dist/jquery.js

--
Jörn Zaefferer

http://bassistance.de
-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-22 Thread Paul McLanahan
I completely agree, Klaus.  I'm not suggesting we rely on that
feature.  I'm suggesting that we use another name for a global eval
function in jQuery so that we don't interfere with the feature while
it's still around. I would definitely not use it in the global eval
function that we're tweaking now.

Jorn: I'm not sure which versions of Safari are affected.  I'll do
some more research and get back to you.  Hopefully it's fixed in
recent versions and we won't have to worry about it.  I don't have SVN
access here at work, or I'd update my working copy and run the test
suite on safari 1.3.2 that I have here.

On 11/22/06, Klaus Hartl <[EMAIL PROTECTED]> wrote:
> With my post I just wanted to point out that I wouldn't rely on features
> that are marked as deprecated and are likely to go away sometime in the
> future. Ok, if it's ten years than forget it :-)

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-22 Thread Klaus Hartl
Paul McLanahan schrieb:
> Well... ok.. Mozilla based browsers.  But that is far from being only
> Firefox (Mozilla, Camino, Flock, Netscape, etc.). It is indeed
> deprecated, but you know how that goes... how long has the font tag
> been deprecated, but browsers will continue supporting it for the
> foreseeable future. I'm sure that eval as an inherited function from
> Object will go away sooner than , but that doesn't mean that it
> won't break code for a whole lot of users now.

Hi Paul, I'm sorry, Firefox has become a synonym to me for the Mozilla 
family (I apologize to Mozilla too).

With my post I just wanted to point out that I wouldn't rely on features 
that are marked as deprecated and are likely to go away sometime in the 
future. Ok, if it's ten years than forget it :-)


-- Klaus

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-22 Thread Paul McLanahan
Well... ok.. Mozilla based browsers.  But that is far from being only
Firefox (Mozilla, Camino, Flock, Netscape, etc.). It is indeed
deprecated, but you know how that goes... how long has the font tag
been deprecated, but browsers will continue supporting it for the
foreseeable future. I'm sure that eval as an inherited function from
Object will go away sooner than , but that doesn't mean that it
won't break code for a whole lot of users now.

On 11/22/06, Klaus Hartl <[EMAIL PROTECTED]> wrote:
> Paul McLanahan schrieb:
> > In most modern browsers (IE Excluded of course), the built in eval
> > function is defined on all objects.  This is designed to combat the
> > problem we're trying to fix now, which is that you can eval code in
> > specific context (in FF for examle) by just calling
> > myObj.eval(codeString);.
>
>
> You are talking of "most modern browsers". As far as I know, the eval is
> only implemented in that way in Firefox (which is far from being most
> modern browsers).
>
> Plus according to the Mozilla Doc it is deprecated:
> http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object:eval
>
> More here:
> http://my.opera.com/hallvors/blog/show.dml/449976
>
> --
> Klaus
>
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-22 Thread Jörn Zaefferer
Hi Brice!
> ---[BEGIN LOAD]---
> click me
> ...
> 
> $('[EMAIL PROTECTED]').click(function(){ alert('worked'); });
> 
> ---[END LOAD]---
>   
That looks better, anyway, doesn't it?
> So pardon my naiveness... but would your fix essentially alleviate the 
> scoping issue and allow functions declared @ ajax loaded content to be 
> available (globally) to IE?
>   
Actually the window.execScript workaround should solve that problem for 
you, for IE. We still need a more reliable solution for Safari then the 
window.setTimeout hack.

-- 
Jörn Zaefferer

http://bassistance.de


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-22 Thread Brice Burgess
Paul McLanahan wrote:
> This would call $.eval implicitly at certain times and in certain
> browsers when we don't expect it, which could possibly override global
> variables or functions which we also aren't expecting.  So my proposal
> above of $.geval() for "global eval" was intended to avoid this
> possibility.  I may be being paranoid, but I can imagine that a bug
> that involved eval being unexpectedly global might be very hard to
> track down.
  I haven't been able to follow this thread entirely, but believe this 
relates to an problem I came across @ 4 days ago when trying to execute 
javascript that was part of the HTML $.load()'ed into the DOM.

 Specifically, the $.load() call returned some HTML resembling

---[BEGIN LOAD]---
click me
...

function newFunc() { alert('worked'); }

---[END LOAD]---

When the loaded "click me" link was pressed in FF/Opera, I would receive 
the "worked" alert. I couldn't get it to work in IE... and thought maybe 
it had to do w/ the getScripts() function called upon the $.load()'ed 
content. After examining this with IE, it appeared to be executing the 
code, but the declared functions were not available. Thus I thought it 
was a scoping thing.. and was able to get around the issue via something 
like;

---[BEGIN LOAD]---
click me
...

$('[EMAIL PROTECTED]').click(function(){ alert('worked'); });

---[END LOAD]---

So pardon my naiveness... but would your fix essentially alleviate the 
scoping issue and allow functions declared @ ajax loaded content to be 
available (globally) to IE?

Gratzie!

~ Brice



___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-22 Thread Jörn Zaefferer
Paul McLanahan schrieb:
> Cool.. Didn't know that.  I do know that the reason that the
> window.setTimeout function is used is that Safari doesn't obey the
> eval.call context, but it does eval scripts in setTimeout globally.
> So we'll have to do a little more browser detection to get it done
> exactly right.  I'll see what I can code up when I get off work.
>   
Didn't know that Safari problem. In that case, we should make the 
exception only for Safari. Do you know which versions of Safari have 
that problem? YUI doesn't support anything below 2.x, I wonder if...

-- 
Jörn Zaefferer

http://bassistance.de


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-21 Thread Klaus Hartl
Paul McLanahan schrieb:
> In most modern browsers (IE Excluded of course), the built in eval
> function is defined on all objects.  This is designed to combat the
> problem we're trying to fix now, which is that you can eval code in
> specific context (in FF for examle) by just calling
> myObj.eval(codeString);.


You are talking of "most modern browsers". As far as I know, the eval is 
only implemented in that way in Firefox (which is far from being most 
modern browsers).

Plus according to the Mozilla Doc it is deprecated:
http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object:eval

More here:
http://my.opera.com/hallvors/blog/show.dml/449976

-- 
Klaus

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-21 Thread Paul McLanahan
Hi again,

Jörn: It looks like you went ahead and implemented the $.eval()
function in ajax.js.  Cool! Thanks! However, I do have 1 more point
besides the Safari problem I mentioned above:

In most modern browsers (IE Excluded of course), the built in eval
function is defined on all objects.  This is designed to combat the
problem we're trying to fix now, which is that you can eval code in
specific context (in FF for examle) by just calling
myObj.eval(codeString);.  However, we've had to resort to all sorts of
things to get around Safari and IE.  However, I'm afraid there may be
unintended consequences if we use the name eval for our x-browser
implementation of global eval because in some browsers I believe that
eval will be called implicitly on "this" in it's current context.
This would call $.eval implicitly at certain times and in certain
browsers when we don't expect it, which could possibly override global
variables or functions which we also aren't expecting.  So my proposal
above of $.geval() for "global eval" was intended to avoid this
possibility.  I may be being paranoid, but I can imagine that a bug
that involved eval being unexpectedly global might be very hard to
track down.

Thanks again Jörn,

Paul

On 11/21/06, Paul McLanahan <[EMAIL PROTECTED]> wrote:
> Cool.. Didn't know that.  I do know that the reason that the
> window.setTimeout function is used is that Safari doesn't obey the
> eval.call context, but it does eval scripts in setTimeout globally.
> So we'll have to do a little more browser detection to get it done
> exactly right.  I'll see what I can code up when I get off work.
>
> Thanks Jörn
>
> On 11/21/06, Jörn Zaefferer <[EMAIL PROTECTED]> wrote:
> > Using window.setTimeout introduces a new problem: The evaluation is
> > asynchronous. According to an Opera resource, the minimal timeout that
> > browsers can handle is 10ms, therefore you can't rely on the evaluation
> > being ready when executing code after the window.setTimeout call. I'd
> > stick with eval.call( window, data) for jQuery's ajax module.
>

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error - Solved?

2006-11-18 Thread Andrea Ercolino

here they don't say much:
---
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/execscript.asp
They don't even know if the second argument is required or optional...

here they give an example for printing in IE4.x that uses execScript:
---
http://msdn.microsoft.com/library/ja/default.asp?url=/library/ja/jpwebwk/author/script/code.asp


I think that the installScript, if passes your quality tests, should be
included in the core of jQuery, maybe renamed jQuery.eval



Paul McLanahan wrote:
> 
> Nice find Andrea! I never happened across that in my googling. Did you
> find any info on what versions of IE support the execScript function?
> 

-- 
View this message in context: 
http://www.nabble.com/getScript-error-tf2652417.html#a7420269
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error - Solved?

2006-11-18 Thread Paul McLanahan
Nice find Andrea! I never happened across that in my googling. Did you
find any info on what versions of IE support the execScript function?

On 11/18/06, Andrea Ercolino <[EMAIL PROTECTED]> wrote:
>
> I've found a solution googling on "eval" which seems to work nicely.
>
> Check the updated test page:
> http://www.mondotondo.com/aercolino/punchcard/test-getScript-error/index.html
>
> Here is the magical function, by Jeff Watkins:
>
> /** Execute a script in the global context. This installs all functions
> defined in this script into the global scope, unless they are
> explicitly created in different scopes.
>
> @param script   the source of the JavaScript to evaluate
>  **/
> function installScript( script )
> {
> if (!script)
> return;
> //  Internet Explorer has a funky execScript method that makes this easy
> if (window.execScript)
> window.execScript( script );
> else
> window.setTimeout( script, 0 );
> }

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error - Solved?

2006-11-18 Thread Andrea Ercolino

I've found a solution googling on "eval" which seems to work nicely.

Check the updated test page:
http://www.mondotondo.com/aercolino/punchcard/test-getScript-error/index.html

Here is the magical function, by Jeff Watkins:

/** Execute a script in the global context. This installs all functions
defined in this script into the global scope, unless they are
explicitly created in different scopes.

@param script   the source of the JavaScript to evaluate
 **/
function installScript( script )
{
if (!script)
return;
//  Internet Explorer has a funky execScript method that makes this easy
if (window.execScript)
window.execScript( script );
else
window.setTimeout( script, 0 );
}



John Resig wrote:
> 
> I've created a trouble ticket for it here:
> http://jquery.com/dev/bugs/bug/407/
> 
> --John
> 
> On 11/17/06, Andrea Ercolino <[EMAIL PROTECTED]> wrote:
>>
>> Hi everybody.
>>
>> While developing the PunchCard widget I've found a problem with getScript
>> in
>> IE7.
>>
>> If you are interested in helping me, I've isolated the issue here:
>> http://www.mondotondo.com/aercolino/punchcard/test-getScript-error/
>>
>> Thanks
>> Andrea
> 
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/getScript-error-tf2652417.html#a7417397
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-17 Thread Andrea Ercolino

OK, thanks Paul.

-- 
View this message in context: 
http://www.nabble.com/getScript-error-tf2652417.html#a7413328
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-17 Thread Paul McLanahan
On 11/17/06, Andrea Ercolino <[EMAIL PROTECTED]> wrote:
>
> I don't understand how to apply the workaround.
>
> It's fine to adjust the script which control the loading, and I think your
> last workaround say how to do it, but I don't understand it. Could you
> please reference my test code?

For your test code the fix must be applied to crc32-safest.js.  You
must change the line:

function crc32( str ) {

to

crc32 =  function( str ) {

As far as my own testing goes, that should work. It changes the scope
of crc32 from local to global.

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-17 Thread Andrea Ercolino

I don't understand how to apply the workaround.

It's fine to adjust the script which control the loading, and I think your
last workaround say how to do it, but I don't understand it. Could you
please reference my test code?


Paul McLanahan wrote:
> 
> As Norbert just pointed out in the thread "Dynamically Loaded Scripts
> in IE 7 - Problems Found and Lessons Learned", it is a scope issue.
> If the functions in your script file loaded via getScript use either
> of the following two methods (they're synonymous) then the functions
> will not be available in the global scope.
> 
> 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(){}
> etc...
> 
> This was tested against SVN jQuery and IE7.
> 
> On 11/17/06, Paul McLanahan <[EMAIL PROTECTED]> wrote:
>> Found and patched the problem in ajax.js where $.getScript and
>> $.getJSON don't do anything if a callback isn't supplied.  The problem
>> is that httpData function isn't called from $.ajax unless there is a
>> callback supplied. Someone please commit if it's deemed a good fix.
>> The only other fix is to add an else after the check for s.success in
>> ajax.js on line 778 to look for types that need httpData to run.
>> Something like
>>
>> // If a local callback was specified, fire it
>> if ( s.success )
>> s.success( jQuery.httpData( xml, s.dataType ), status );
>> else if ( s.dataType=='script' || s.dataType=='json' )
>> jQuery.httpData( xml, s.dataType );
>>
>> But I think the patch below might be easier... up to you committers.
>>
>> Index: ajax.js
>> ===
>> --- ajax.js (revision 603)
>> +++ ajax.js (working copy)
>> @@ -420,11 +420,7 @@
>>  * @cat AJAX
>>  */
>> getScript: function( url, callback ) {
>> -   if(callback)
>> -   jQuery.get(url, null, callback, "script");
>> -   else {
>> -   jQuery.get(url, null, null, "script");
>> -   }
>> +   jQuery.get(url, null, callback||function(){}, "script");
>> },
>>
>> /**
>> @@ -465,7 +461,7 @@
>>  * @cat AJAX
>>  */
>> getJSON: function( url, data, callback ) {
>> -   jQuery.get(url, data, callback, "json");
>> +   jQuery.get(url, data, callback||function(){}, "json");
>> },
>>
>> /**
>>
>>
>> I'm still looking for the IE7 problem.
>>
>> Paul
>>
>>
>> On 11/17/06, John Resig <[EMAIL PROTECTED]> wrote:
>> > I've created a trouble ticket for it here:
>> > http://jquery.com/dev/bugs/bug/407/
>> >
>> > --John
>> >
>> > On 11/17/06, Andrea Ercolino <[EMAIL PROTECTED]> wrote:
>> > >
>> > > Hi everybody.
>> > >
>> > > While developing the PunchCard widget I've found a problem with
>> getScript in
>> > > IE7.
>> > >
>> > > If you are interested in helping me, I've isolated the issue here:
>> > > http://www.mondotondo.com/aercolino/punchcard/test-getScript-error/
>> > >
>> > > Thanks
>> > > Andrea
>> >
>> > ___
>> > jQuery mailing list
>> > discuss@jquery.com
>> > http://jquery.com/discuss/
>> >
>>
> 
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/getScript-error-tf2652417.html#a7410144
Sent from the JQuery mailing list archive at Nabble.com.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-17 Thread Paul McLanahan
On 11/17/06, John Resig <[EMAIL PROTECTED]> wrote:
> I've created a trouble ticket for it here:
> http://jquery.com/dev/bugs/bug/407/

I updated the ticket with the info from my previous post. It's not
fixed, but it is a work around.

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-17 Thread Paul McLanahan
As Norbert just pointed out in the thread "Dynamically Loaded Scripts
in IE 7 - Problems Found and Lessons Learned", it is a scope issue.
If the functions in your script file loaded via getScript use either
of the following two methods (they're synonymous) then the functions
will not be available in the global scope.

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(){}
etc...

This was tested against SVN jQuery and IE7.

On 11/17/06, Paul McLanahan <[EMAIL PROTECTED]> wrote:
> Found and patched the problem in ajax.js where $.getScript and
> $.getJSON don't do anything if a callback isn't supplied.  The problem
> is that httpData function isn't called from $.ajax unless there is a
> callback supplied. Someone please commit if it's deemed a good fix.
> The only other fix is to add an else after the check for s.success in
> ajax.js on line 778 to look for types that need httpData to run.
> Something like
>
> // If a local callback was specified, fire it
> if ( s.success )
> s.success( jQuery.httpData( xml, s.dataType ), status );
> else if ( s.dataType=='script' || s.dataType=='json' )
> jQuery.httpData( xml, s.dataType );
>
> But I think the patch below might be easier... up to you committers.
>
> Index: ajax.js
> ===
> --- ajax.js (revision 603)
> +++ ajax.js (working copy)
> @@ -420,11 +420,7 @@
>  * @cat AJAX
>  */
> getScript: function( url, callback ) {
> -   if(callback)
> -   jQuery.get(url, null, callback, "script");
> -   else {
> -   jQuery.get(url, null, null, "script");
> -   }
> +   jQuery.get(url, null, callback||function(){}, "script");
> },
>
> /**
> @@ -465,7 +461,7 @@
>  * @cat AJAX
>  */
> getJSON: function( url, data, callback ) {
> -   jQuery.get(url, data, callback, "json");
> +   jQuery.get(url, data, callback||function(){}, "json");
> },
>
> /**
>
>
> I'm still looking for the IE7 problem.
>
> Paul
>
>
> On 11/17/06, John Resig <[EMAIL PROTECTED]> wrote:
> > I've created a trouble ticket for it here:
> > http://jquery.com/dev/bugs/bug/407/
> >
> > --John
> >
> > On 11/17/06, Andrea Ercolino <[EMAIL PROTECTED]> wrote:
> > >
> > > Hi everybody.
> > >
> > > While developing the PunchCard widget I've found a problem with getScript 
> > > in
> > > IE7.
> > >
> > > If you are interested in helping me, I've isolated the issue here:
> > > http://www.mondotondo.com/aercolino/punchcard/test-getScript-error/
> > >
> > > Thanks
> > > Andrea
> >
> > ___
> > jQuery mailing list
> > discuss@jquery.com
> > http://jquery.com/discuss/
> >
>

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-17 Thread Paul McLanahan
Found and patched the problem in ajax.js where $.getScript and
$.getJSON don't do anything if a callback isn't supplied.  The problem
is that httpData function isn't called from $.ajax unless there is a
callback supplied. Someone please commit if it's deemed a good fix.
The only other fix is to add an else after the check for s.success in
ajax.js on line 778 to look for types that need httpData to run.
Something like

// If a local callback was specified, fire it
if ( s.success )
s.success( jQuery.httpData( xml, s.dataType ), status );
else if ( s.dataType=='script' || s.dataType=='json' )
jQuery.httpData( xml, s.dataType );

But I think the patch below might be easier... up to you committers.

Index: ajax.js
===
--- ajax.js (revision 603)
+++ ajax.js (working copy)
@@ -420,11 +420,7 @@
 * @cat AJAX
 */
getScript: function( url, callback ) {
-   if(callback)
-   jQuery.get(url, null, callback, "script");
-   else {
-   jQuery.get(url, null, null, "script");
-   }
+   jQuery.get(url, null, callback||function(){}, "script");
},

/**
@@ -465,7 +461,7 @@
 * @cat AJAX
 */
getJSON: function( url, data, callback ) {
-   jQuery.get(url, data, callback, "json");
+   jQuery.get(url, data, callback||function(){}, "json");
},

/**


I'm still looking for the IE7 problem.

Paul


On 11/17/06, John Resig <[EMAIL PROTECTED]> wrote:
> I've created a trouble ticket for it here:
> http://jquery.com/dev/bugs/bug/407/
>
> --John
>
> On 11/17/06, Andrea Ercolino <[EMAIL PROTECTED]> wrote:
> >
> > Hi everybody.
> >
> > While developing the PunchCard widget I've found a problem with getScript in
> > IE7.
> >
> > If you are interested in helping me, I've isolated the issue here:
> > http://www.mondotondo.com/aercolino/punchcard/test-getScript-error/
> >
> > Thanks
> > Andrea
>
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-17 Thread jyl
Does not work on IE6 for me either.

--Jacob

> I've created a trouble ticket for it here:
> http://jquery.com/dev/bugs/bug/407/
>
> --John
>
> On 11/17/06, Andrea Ercolino <[EMAIL PROTECTED]> wrote:
>>
>> Hi everybody.
>>
>> While developing the PunchCard widget I've found a problem with
>> getScript in
>> IE7.
>>
>> If you are interested in helping me, I've isolated the issue here:
>> http://www.mondotondo.com/aercolino/punchcard/test-getScript-error/
>>
>> Thanks
>> Andrea
>
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>



___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] getScript error

2006-11-17 Thread John Resig
I've created a trouble ticket for it here:
http://jquery.com/dev/bugs/bug/407/

--John

On 11/17/06, Andrea Ercolino <[EMAIL PROTECTED]> wrote:
>
> Hi everybody.
>
> While developing the PunchCard widget I've found a problem with getScript in
> IE7.
>
> If you are interested in helping me, I've isolated the issue here:
> http://www.mondotondo.com/aercolino/punchcard/test-getScript-error/
>
> Thanks
> Andrea

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] $.getScript error message

2006-09-09 Thread ashutosh bijoor
Good point, Arash. I think this bug does need to be fixed. -AshutoshOn 9/9/06, Arash Yalpani <[EMAIL PROTECTED]
> wrote:Calling $.getScript with only one parameter, being the url, I always get
this message (on FF):  "data has no properties"It points to line 226 of http://jquery.com/dev/svn/jquery/src/ajax/ajax.js
if ( data.constructor == Function ) {  type = callback;  callback = data;  data = "">}What I do is as simple as this:$.getScript('
http://newsride/shared/fetch/account/login/login.js?v=20060620-1');So I thought changing line 226 to  if ( data && data.constructor == Function ) {should fix the problem and it did. Could someone with more insight
judge, if this is a bug that should be fixed in JQuery?Arash___jQuery mailing listdiscuss@jquery.com
http://jquery.com/discuss/-- Reach1to1 Communicationshttp://www.reach1to1.com[EMAIL PROTECTED]
98201-94408
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/