Bill Robertson's Blog

Sys.ScriptLoadFailedException when adding ScriptReferences

I added a manual ScriptReference to an embedded resource but was receiving a client side error:

Error: Sys.ScriptLoadFailedException: The script <url for script> could not be loaded or does not contain the Sys.Application.notifyScriptLoaded() callback.

I found this post to help with the problem.  Ajax now loads the various script files in an asynchronous manner, and it is the responsibility of the script file, when completed to call execute code similar to the following:

if( Sys && Sys.Application ){
   Sys.Application.notifyScriptLoaded();
}

The if block might not be required, but if you are using a javascript file outside of Atlas you probably should protect it.  However on Luis's site, he missed a casing on the method call notifyScriptLoaded.  I'm sure he will get that fixed, but just be aware if you copy and paste.  :)

 

 

 

 

Comments

Jim said:

SWEET GEORGIA BROWN!!!  That was driving me crazy - fixed now thanks to you!

=)

# December 24, 2006 8:41 PM

Panagiotis Poulos said:

You are a life saver!!! I still can't believe I finally got it working - thanks to you!

Cheers!

# March 2, 2007 11:39 AM

Helen said:

I found that I was still getting error messages from IE when I was just checking if(Sys && Sys.Application) when I used the same javascript file in a non-ajax project.

I found that this solved the problem:

if( typeof(Sys) != "undefined" && typeof(Sys.Application) != "undefined" ){

  Sys.Application.notifyScriptLoaded();

}

# April 25, 2007 5:42 AM

G said:

If you're adding combined scripts using the ScriptManager control, apparently you no longer require this call.

Unfortunately I still periodically get it, most of the time when first compiling the app - think it's a bug in the control toolkit.  Or should I say - another bug in the toolkit lol...

# July 2, 2008 7:34 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)