Solved

Microsoft JScript runtime error: '$' is undefined - with jquery slider

Posted on 2011-09-05
5
1,547 Views
Last Modified: 2012-05-12
hello,

i am getting the following error "Microsoft JScript runtime error: '$' is undefined" when i moved a website from one computer to another.  no code changed.  The initial computer was running visual studio web developer 2008, the new computer has vs web developer 2010.  I can not seem to figure out what is different, the project still references the same .net 3.5 framework.  The code works fine when put on the live web server, but I need to be able to run it locally.

the error is thrown on the following line of code in the aspx page head: $(function(){  (shown below)
 
<script type="text/javascript" src="../js/jquery-1.2.6.min.js"></script> 
	<script type="text/javascript" src="../js/jquery-easing-1.3.pack.js"></script> 
	<script type="text/javascript" src="../js/jquery-easing-compatibility.1.2.pack.js"></script> 
	<script type="text/javascript" src="../js/coda-slider.1.1.1.pack.js"></script> 	
	<script type="text/javascript"> 
	
		var theInt = null;
		var $crosslink, $navthumb;
		var curclicked = 0;
		
		theInterval = function(cur){
			clearInterval(theInt);
			
			if( typeof cur != 'undefined' )
				curclicked = cur;
			
			$crosslink.removeClass("active-thumb");
			$navthumb.eq(curclicked).parent().addClass("active-thumb");
				$(".stripNav ul li a").eq(curclicked).trigger('click');
			
			theInt = setInterval(function(){
				$crosslink.removeClass("active-thumb");
				$navthumb.eq(curclicked).parent().addClass("active-thumb");
				$(".stripNav ul li a").eq(curclicked).trigger('click');
				curclicked++;
				if( 6 == curclicked )
					curclicked = 0;
				
			}, 3000);
		};
		
		$(function(){
			
			$("#main-photo-slider").codaSlider();
			
			$navthumb = $(".nav-thumb");
			$crosslink = $(".cross-link");
			
			$navthumb
			.click(function() {
				var $this = $(this);
				theInterval($this.attr('href').slice(1) - 1);
				return false;
			});
			
			theInterval();
		});
	</script>

Open in new window

 

the error seems to indicate that the function cannot be found in the referenced java script files, but these exact libraries are working fine on other systems, so it has to be something in my environment that is killing it, but i don't know where to look

thanks in advance
0
Comment
Question by:jordanking
  • 3
5 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 250 total points
ID: 36484941
You go to browser address bar where this error occur and replace the page name with the first js file reference.
Like this:
When your page was:
http://your.server.com/your/folders/yourpage.htm

Then replace it:
http://your.server.com/your/folders/../js/jquery-1.2.6.min.js

If you get 404 then that was it!

0
 
LVL 11

Assisted Solution

by:Kusala Wijayasena
Kusala Wijayasena earned 250 total points
ID: 36485772
Most of the times, cause for " '$' is undefined" is missing reference to core jquery file (in your case jquery-1.2.6.min.js). So just check whether all the reference are OK in your project

-Kusala
0
 
LVL 1

Author Comment

by:jordanking
ID: 36486318
thanks zvonko and kusala,

I put the explicit path to all .js files in the browser url exactly as written in the html include, and they all work, the files are referenced fine and they all work perfectly when on the live remote server.

I thought it might be because .net 3.5 is the framework for the website and I am running windows 7, but i found out that windows 7 induces it in the turn on and off windows features through the control panel.  I made sure it was turned on, but it did no solve my problem.  

could there be another reason the .js files are not being accessed?
0
 
LVL 1

Author Closing Comment

by:jordanking
ID: 36486417
thanks
0
 
LVL 1

Author Comment

by:jordanking
ID: 36486421
okay, thanks for sending me in the right direction.  The virtual path is the website settings within visual studio was set wrong, i changed it back to "/" like i had it on the previous computer and everything worked.  That explained why the files were not loading, i used firebug in firefox to get the actual path being requested which helped me find the virtual path setting.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…

747 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

12 Experts available now in Live!

Get 1:1 Help Now