Solved

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

Posted on 2011-09-05
5
1,560 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
abstract class C# 1 31
Phone Does Not Abide By CSS Breakpoint For Navigation Controls 6 20
ASP.NET MVC - Views 3 19
Why use this lambda? 12 35
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…

856 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