ASP.NET Cafe
Tips and Tricks

Better call for NotifyScriptLoaded in AJAX

Sunday, 27 July 2008 14:54 by Dmitriy
Already on Bora bora ? I'm not...

Recently found one thing. Perhaps in docs for AJAX client or somewhere else was such line:

Sys.Application.notifyScriptLoaded(); 

You need to write this line at the end of your JS files. But this can cause the problems if you wish to re-use this code in non-ajax enviroment. For this better to use following line:

if (typeof(Sys) !== 'undefined')  Sys.Application.notifyScriptLoaded(); 

This makes things a bit better. Also, it answers another question - "Testing for defined variables in Javascript".  Sometimes I see the code like:

if( Sys )...  // And this will fail in case Sys is undefined. 

 That's all for now, it's summer. Everybody enjoy their resort life. But I'm still working.

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   ASP.NET
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (0) | Comment RSSRSS comment feed

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Preview

December 4. 2008 11:23