I am having some errors linking to my css files from my html. I am getting the following errors.
GET http://localhost:3000/app/assets/javascripts/bootstrap.min.css
habits:30
GET http://localhost:3000/app/assets/stylesheets/application.scss
habits:34
GET http://localhost:3000/assets/js/ie-emulation-modes-warning.js
habits:52
GET http://localhost:3000/assets/js/ie10-viewport-bug-workaround.js
habits.self-f894a4f031f58f24694feda9c89f464976d99c2eda34ee3f03c956dc29757a67.js?body=1:8
Uncaught ReferenceError: Handsontable is not defined
I know that the first four is from an error referencing the css file from my html file, but what is the last error for? And how would I fix it?
The Uncaught ReferenceError sometimes means you don't have your javascript files in the correct order. For instance, if a script relies on jQuery but gets loaded first, you'll get this error.
Without viewing the entire code it's impossible to say exactly where the problem lies, but I've found that linking jQuery first, then other scripts, generally fixes the error.
One way to avoid this error is to put a conditional script in the header like so:
<script type="text/javascript">
if (typeof jQuery == 'undefined') {
document.write("<script type=\"text/javascript\" src=\"[jquery CDN of your choice]\"></" + "script>");
}
</script>
Related
Is there a way to see which function is causing this error? Or which button I'm binding to that isn't on the page? Ive got 7+ js files linking to my php page and I can't seem to find which binding, or missing function is causing this error.
I checked out this link uncaught type error and found that It could be two different issues. But it doesn't tell me how to search for the issue. Chrome usually will give me a line number when I've got syntax error or otherwise.
I'm using Google Analyticator and my website is http://gestionalemagazzinoonline.it/
You can see the error in the javascript console.
I think that is the suspected file:
https://github.com/wp-plugins/google-analyticator/blob/master/google-analyticator.php
The problem is also if i disable the plugin, or if i change the source code i don't see the changes (maybe there's a cache?).
How can I fix?
Script tags are meant to write javascript in them, and not html.
You have a script block inside a script block. Remove that, and it will work all fine.
for some reason when i try to load jquery via cdn, it works perfectly
script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"
however, when i try to load it using the local files, it does not work
script type="text/javascript" src="javascripts/jquery-1.11.2.min.js"
and displays this error:
Uncaught SyntaxError: Unexpected token < jquery-1.11.2.min.js:1
i must say that my server is running on node.js
it seems you have syntax error with your tag.
try this.
<script type="text/javascript" src="javascripts/jquery-1.11.2.min.js"></script>
It seems as though there is an error occurring inside jquery-1.11.2.min.js. Not in the document which contains the script tag. So, the question is: why does your local copy of jquery-1.11.2.min.js contain a <? The answer is that it most likely doesn't. The request for jquery-1.11.2.min.js is probably resulting in a HTML response, which the browser attempts to load as JavaScript, and fails on the first character. Ensure that javascripts/jquery-1.11.2.min.js is the correct path to your JavaScript file.
It can be shown that this is the case because a SyntaxError is a JavaScript error. MDN says the following (emphasis mine):
A SyntaxError is thrown when the JavaScript engine encounters tokens or token order that does not conform to the syntax of the language when parsing code.
So, the error is being thrown by the JavaScript engine, which means that the browser is actually trying to load a script file. As you can see from the error message, the error is thrown at jquery-1.11.2.min.js:1, which is line one of jquery-1.11.2.min.js. You can reproduce the same error message using the following code saved in a file named foo.html:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="foo.html"></script>
</head>
<body></body>
</html>
Alternatively, you can view a demonstration of equivalent code here (check your console).
I'm trying to improve the load time of my web page using LABjs. However I'm getting 'Undefined not a function' in relation to jQuery.cookie('mycookie') which I'm using in my own jQuery script.
I'd be grateful for some advice on how to implement LABjs to deal with this as I don't quite understand the documentation.
Here's the code I have so far:
HTML
I have jQuery and LAB.min.js in the footer of my HTML page
<script type="text/javascript" src="myfolder/jquery1.9.1.js"></script>
<script type="text/javascript" src="myfolder/LAB.min.js"></script>
LAB.min.js file
Here I load my scripts in order. ratings.js depends on jquery-cookie.js, so I've included a wait() first to make sure that jquery-cookie.js is loaded first.
//ALL THE LABjs code is here, but not included on this post!
$LAB.setGlobalDefaults({Debug:true});
.script("myfolder/bootstrap.min.js")
.script("myfolder/jquery-cookie.js")
.wait()
.script("myfolder/ratings.js");
ratings.js
ratings.js is a long piece of code contained within the jQuery(document).ready function.
jQuery(document).ready(function() {
//LOTS OF CODE HERE
if(jQuery.cookie('mycookie')==null){
//LOTS OF CODE HERE
}
//LOTS OF CODE HERE
});
I'm getting an error in ratings.js relating to the line of code containing jQuery.cookie('mycookie'). It says "Uncaught type error: undefined is not a function"
From what I understand, jQuery.cookie() isn’t yet defined when I try to pass it to .wait(). What is the best way to get this to work, keeping in mind that I want to keep ratings.js in a separate js file because it contains a lot of code and is one of many similar js files that also throw up the same error when I load them with LABjs.
Many thanks!
Katie
You should be able to remove the link to jQuery in your HTML and just have LABJS to load all of the scripts. This will load jQuery before Bootstrap or your plugin:
$LAB
.setGlobalDefaults({Debug:true}) // removed semi-colon
.script("myfolder/jquery1.9.1.js")
.wait()
.script("myfolder/bootstrap.min.js")
.script("myfolder/jquery-cookie.js")
.wait()
.script("myfolder/ratings.js");
(Note that you had a semicolon in your code that was likely breaking something too):
Here is my website
If I open it in Chrome sometime I don't see the menu function on hover.
In the console I get this
Uncaught ReferenceError: jQuery is not defined /catalog/view/javascript/journal/pnotify/jquery.pnotify.min.js:1
Uncaught ReferenceError: jQuery is not defined /catalog/view/javascript/journal/cookie.js:1
Uncaught ReferenceError: jQuery is not defined /catalog/view/javascript/jquery/colorbox/jquery.colorbox.js:82
Uncaught ReferenceError: $ is not defined /catalog/view/javascript/jquery/tabs.js:1
Uncaught TypeError: undefined is not a function
I know this is an old error and I have seen several questions on SO,
but none of them helped me
If you open the same site in Firefox , it warns you about some unresponsive JavaScript and once you click OK it works fine, I am not really sure that what is the issue behind this, if it is jQuery issue, it would be difficult to go in each file and debug it,
Anyone who can assist me by looking at console logs?
You have set the async attribute to jQuery include script like <script async src="catalog/view/javascript/jquery/jquery-1.7.1.min.js"></script> remove it.
<script src="catalog/view/javascript/jquery/jquery-1.7.1.min.js"></script>
In normal circumstances the scripts are executed in the order in which they are included. But since you have used the async flag the execution of core jQuery library will be asynchronous. So there are chances that it will be executed after the rest of script files which needs jQuery library.
Move this line without async
<script src="catalog/view/javascript/jquery/jquery-1.7.1.min.js"></script>
to the top of your javascript included files
and make sure there is no conflict between jquery and other library
Hi i was also having the same problem. I got the solution too in my way. you just look at my code. if it does the same thing on your project correct it.
function fill_grid()
{
//some of my work
var para=new Array();
para[0]="id";
para[1]=retcond("");
}
function retcond(posid)
{
//
var cond="where pfid="'19282'";
retcond=cond;
return retcond;
}
The above code was working fine at the first button_click. but at second click gave me the same error you got. now I changed the "retcond()" function into,
function retcond(posid)
{
//
return cond;
}
Since i didn't declare the variable name, it made me troubled. now it solved. hope this can give you any idea.