I am getting this error while function call:
Error:"0x800a138f - Microsoft JScript runtime error: The value of the property 'function1' is null or undefined, not a Function object"
function1 is getting called on click of a button
Irvin Dominin
31k9 gold badges82 silver badges114 bronze badges
asked Jun 25, 2013 at 6:19
-
Seems like you missed () in method callingYD1m– YD1m2013年06月25日 06:23:05 +00:00Commented Jun 25, 2013 at 6:23
-
post the code so that we can evaluate and track what causes the errorNesmar Patubo– Nesmar Patubo2013年06月25日 06:23:06 +00:00Commented Jun 25, 2013 at 6:23
-
Please post the full stack trace, so that we can see who's calling at the wrong moment.Ravi Kavaiya– Ravi Kavaiya2013年06月25日 06:29:45 +00:00Commented Jun 25, 2013 at 6:29
2 Answers 2
Your script is not executed when the DOM is ready. You should adjust your code like this..
$(function() {
$("#button").click( function() {
alert('button clicked');
});
});
davidcondrey
36.3k18 gold badges119 silver badges138 bronze badges
answered Jun 25, 2013 at 6:24
Comments
It can be several things but since I dont have your code and I see you using jQuery I would recommend to do the following:
- As Sagar Vaghela said, your JS code may be executed when the DOM element is not ready, to solve this you should as good practice wrap your code in $(document).ready(function () {//Your code goes here}).
- I also recomend to play with your jQuery selector when the web page is ready so you are certain that you are using the proper selector, you cant imagine how many times I could have failed on this last one.
- And last you should be sure that your JS file is being loaded by setting a breakpoint somewhere in the code using Firebug or Google Chrome dev tools.
I hope this helps :)
Comments
default