Results 1 to 3 of 3
-
May 3rd, 2012, 01:15 PM #1
jQuery - uncaught reference error!
Ughhhh Annoying... I am using jQuery - and it's not working for me. Very simply I define a function, and call it. Alas - no - I get the uncaught reference error. Maybe I have done something very stupid - but I cant see it.
THE CODE:SO it's all about where is the jQuery and how it is being initialised .. well ive tried it all ..Code:function typer() { // my code }; var muse = setTimeout('typer()',500); // uncaught reference error!
for starters, im loading it at the very end of my code via a 'script.js', just above the </html> .. nd ive tried the following
// U R ECode:$(document).ready(function () {// my code });
// U R ECode:(function($) {// my code })(jQuery);
// U R ECode:(function() {// my code })();
Banana's! they should all work >... IF I just put the code in script tags - then it works ...
Any ideas?!
-
May 3rd, 2012, 04:28 PM #2
Why not setTimeout(typer, 500) ? Is line 3 actually in the same scope as the two above it, or did you just combine them for this post?
-
May 3rd, 2012, 05:14 PM #3
well thanks Krilnon - setTimeout(typer, 500) works!
BUT ALL the javascript documentation that ive read explains the usage function to be called as a string.
FYI - those above were for examples - and not within the same scope.
OMT - setTimeout("typer()", 500) will work IF I just have the script hardcoded into the HTML. Whereas, when I load it in as a *.js .. then this problem occurs with the function call being a string in the set timeout function.
K - thanks again - I can leave this meteor shower i've been in .

Reply With Quote

Bookmarks