Solved

Getting Object Expected errors trying to use jQuery

Posted on 2008-09-29
4
7,520 Views
Last Modified: 2012-05-05
I am trying to take the following very simple page and make it work in a visual studio project. I either get a "Javascript Runtime Error: Object Expected" or a "$ is not a recognized command" I have made sure the library file is where it is supposed to be. Any clues as to why I am not having any luck with this?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html>                                                                  
 <head>                                                                  
 <script type="text/javascript" src="../jquery-1.2.6.js"></script>          
 <script type="text/javascript">
     // we will add our javascript code here         
     $(document).ready(function() {
         // do stuff when DOM is ready
     });                                 
 </script>                                                               
 </head>                                                                 
 <body>  
 
                                                                
   <!-- we will add our HTML content here -->                                        
 </body>                                                                 
 </html>

Open in new window

0
Comment
Question by:SGyves
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 22604192
a) your JS is not where the BROWSER thinks it is
b) the js file is corrupt
c) the browser does not think it is javascript (server serves it with the wrong mime type)

I think a)

Try Firefox 3.03 and look in the JS console
0
 

Author Comment

by:SGyves
ID: 22619638
The answer is 'a'. The designer seemed to think it could fins the js file with the src specified as "../jquery-1.2.6.js" however...at runtime...it could not. When I dragged the js file into the page head..it made its own entry and it was "jquery-1.2.6.js"   Made all the difference in the world. Not before nearly driving me crazy. Because if you are flat out wrong with the location of the file...before you even run the page...the intellisense is telling you that it cannot find the file. Both of these formats were okay with intellisense, but only the latter ran.
0
 

Author Closing Comment

by:SGyves
ID: 31501400
Have some points.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 22621533
:) Great
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
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…

734 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