Solved

undefined error

Posted on 2012-03-23
5
173 Views
Last Modified: 2012-03-27
i get an error in internet explorer only pointing hello in undefined. how do i resolve it. what am i missing?

<script type="text/javascript">hello.spend();</script>
0
Comment
Question by:jcbmtt
  • 2
  • 2
5 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 37756060
hello is not defined yet..that is why you get 'undefined error'
0
 
LVL 7

Expert Comment

by:Lalit Chandra
ID: 37756085
hello is undefined means that browser is not able to find that hello..
To Understand,change your code with the following line for demonstration only


<script type="text/javascript">

var hello = {
    spend =function() {
          alert("This is the sample only");
     }
}


hello.spend();

</script>

Hope this will fix up your problem.
0
 

Author Comment

by:jcbmtt
ID: 37756143
chandra

is ur function harmless? i dont want the function to do anything. its just to beat the undefined error.
0
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 37756215
it is quite harmless, you can make it more harmless by doing it

var hello = {
    spend =function() {}
};
0
 

Author Closing Comment

by:jcbmtt
ID: 37770042
thanks
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…
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…

774 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