Solved

jQuery / "'Sys' is undefined"

Posted on 2011-03-07
4
1,399 Views
Last Modified: 2012-05-11
Hi.  I am trying to use some way-cool jQuery alerts in my ASP.NET website.

One of the first alert() calls that I'm going to want to eliminate is actually called from my Page_Render() event on the server side.  It's a browser warning about IE.

After referencing this jQuery tool's js/css files and trying my app out in IE (so that it executes the RegisterClientScript() call that adds the new JS), I get this

'Sys' is undefined

error.  It happens in this part of the page's execution:

      $(document).ready(function() {
         Sys.Application.add_load(function() { Page_onLoad(); });
      });

Does not happen in Firefox...but then, remember, it's the server-side script registration that's bombing out with the new jQuery alert() tool.  

This same server-side code does not fail with the old conventional alert() call.

Now, here's the deal.  I can use Google, and there are tons and tons of "here's how to fix this problem" sites on the net that deal with this specific error.

I CAN comb through those, and I AM combing through those now.  But I'm posting this question in an attempt to find someone who has dealt with this particular error and has specific knowledge or experience with it to help me out.

I repeat:  I can use Google, and AM using Google, so please don't just send me links.  I've tried tons and tons of "fixes", and am STILL trying them.  None have worked.  Please--I need someone with knowledge/experience specific to this problem.

Thank you!  Happy to post web.config markup, or whatever, if that helps.
0
Comment
Question by:bamapie
  • 3
4 Comments
 

Accepted Solution

by:
bamapie earned 0 total points
ID: 35058975
I fixed this by adding the "$(document).ready(function() {" text around the server-side-added JS.  But I'll keep this question open in case someone has some insight more than just the workaround I'm posting.
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 35060785
I haven't done much reading on jQuery, but from what I understand your solution seems to be the "correct" way, not a workaround.  Otherwise, your JavaScript runs before the jQuery libraries have been loaded - hence the Sys is not defined error.

You can accept your own response as the correct answer to this question.
0
 

Assisted Solution

by:bamapie
bamapie earned 0 total points
ID: 35060815
OK, thanks.  It was just surprising that nothing in this equation gave me any trouble until I began using this "jquery.alerts" library.  Suddenly my registering of JS on the server was a problem...just didn't seem right.

Thanks again.
0
 

Author Closing Comment

by:bamapie
ID: 35115345
My workaround looks to be the conventional way of doing this.  Not clear on why this suddenly became a surprise on this jquery.alerts library.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now