Fix for bug #407, yet to be tested

This commit is contained in:
Jörn Zaefferer 2006-11-20 20:37:28 +00:00
parent 7cc550727c
commit 46faa03820
2 changed files with 14 additions and 6 deletions

View file

@ -122,7 +122,7 @@ jQuery.fn.extend({
return this.find('script').each(function(){ return this.find('script').each(function(){
if ( this.src ) if ( this.src )
// for some weird reason, it doesn't work if the callback is ommited // for some weird reason, it doesn't work if the callback is ommited
jQuery.getScript( this.src, function() {} ); jQuery.getScript( this.src );
else else
eval.call( window, this.text || this.textContent || this.innerHTML || "" ); eval.call( window, this.text || this.textContent || this.innerHTML || "" );
}).end(); }).end();
@ -581,9 +581,12 @@ jQuery.extend({
if ( s.ifModified && modRes ) if ( s.ifModified && modRes )
jQuery.lastModified[s.url] = modRes; jQuery.lastModified[s.url] = modRes;
// If a local callback was specified, fire it // process the data (runs the xml through httpData regardless of callback)
var data = jQuery.httpData( xml, s.dataType );
// If a local callback was specified, fire it and pass it the data
if ( s.success ) if ( s.success )
s.success( jQuery.httpData( xml, s.dataType ), status ); s.success( data, status );
// Fire the global callback // Fire the global callback
if( s.global ) if( s.global )
@ -678,8 +681,13 @@ jQuery.extend({
var data = !type && ct && ct.indexOf("xml") >= 0; var data = !type && ct && ct.indexOf("xml") >= 0;
data = type == "xml" || data ? r.responseXML : r.responseText; data = type == "xml" || data ? r.responseXML : r.responseText;
// If the type is "script", eval it // If the type is "script", eval it´in global context
if ( type == "script" ) eval.call( window, data ); if ( type == "script" ) {
if (window.execScript)
window.execScript( data );
else
window.setTimeout( data, 0 );
}
// Get the JavaScript object, if JSON is used. // Get the JavaScript object, if JSON is used.
if ( type == "json" ) eval( "data = " + data ); if ( type == "json" ) eval( "data = " + data );

View file

@ -119,7 +119,7 @@ test("$.getScript(String, Function) - with callback", function() {
stop(); stop();
$.getScript("data/test.js", function() { $.getScript("data/test.js", function() {
ok( foobar == "bar", 'Check if script was evaluated' ); ok( foobar == "bar", 'Check if script was evaluated' );
start(); setTimeout(start, 100);
}); });
}); });