[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 182
  • Last Modified:

undefined error

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
jcbmtt
Asked:
jcbmtt
  • 2
  • 2
1 Solution
 
Gurvinder Pal SinghCommented:
hello is not defined yet..that is why you get 'undefined error'
0
 
Lalit ChandraCommented:
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
 
jcbmttAuthor Commented:
chandra

is ur function harmless? i dont want the function to do anything. its just to beat the undefined error.
0
 
Gurvinder Pal SinghCommented:
it is quite harmless, you can make it more harmless by doing it

var hello = {
    spend =function() {}
};
0
 
jcbmttAuthor Commented:
thanks
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now