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.
Related
I have a web age containing both PHP(7.3) which is first in the file and HTML(5) shown below.
In the PHP, I do the following:
echo '<script>gotoLogIn();</script>';
In the HTML, I have the following:
<script>
function gotoLogIn() {
alert("Now going elsewhere.");
window.location.replace("http://localhost/xxxx/yyyy/zzzz/index.php");
}
</script>
When the PHP "echo" is executed, I get "Uncaught ReferenceError: gotoLogIn is not defined which shows up on the Firefox Web Console". I get the same error on Chrome.
I've tried a number of things including the answer to a similar question on SO with no joy.
I am at a loss. This is the technique I have found in several sites.
Are they old references and is there a newer way to do this or a security action that needs to be taken.
All help appreciated.
Regards,
Jim
Well as the others already mentioned you can do it with PHP header (https://www.php.net/manual/de/function.header.php)
header("LOCATION: index.php");
If you still want to use JavaScript you have to ensure that your function called by php is executed after the Script has been defined within your html.
You can do this the following way have a look at this thread Pure JavaScript equivalent of jQuery's $.ready() - how to call a function when the page/DOM is ready for it
(Disclaimer: this is a self-answered question)
I wanted to set up some Select2 to my form fields while in a Django admin panel (specifically in the change_list.html template). So I added the neccesary scripts to the page (not the full version), but when it loads, I get this errors:
Select2: An instance of jQuery or a jQuery-compatible library was not found. Make
sure that you are including jQuery before Select2 on your web page.
TypeError: a is undefined
TypeError: e is undefined
TypeError: $ is not a function
And when you search for one of those errors (well, not the first and last ones), the answers aren't on the same subject (normally it has to do with a bad processResults setup, or problems with Bootstrap) or in the docs neither.
How can I fix it?
There are two steps involved fixing it:
Setting a var called $
This one is the first thing you think of when you see the last line (TypeError: $ is not a function), and all scripts normally use it (who doesn't uses $ in their scripts?). But when you modify it, you still get these errors:
TypeError: a is undefined
TypeError: e is undefined
So, we have to go deeper...
Setting a var called jQuery
This one can be a little hidden, as we have to dig into the select2.js script (you normally use the minified version, so only $ is showed instead).
Looks like a var called jQuery is used sometimes, so you also have to set it up in your JS.
How the fix should look like
Add this script before your Select2 scripts:
<script type="text/javascript">
// To prevent errors for Select2 JS
var $ = django.jQuery;
var jQuery = django.jQuery;
</script>
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>
I have been asked to fix an issue with a website and I am encountering an issue with a JavaScript error.
On the home page, [removed website link], I am receiving the error Uncaught TypeError: undefined is not a function. However, the function being called on that line (line 30) should exist, as the jQuery plugin is being loaded.
The call-stack just shows a series of anonymous functions pointing towards the jQuery file. I am having trouble determining why this is producing an undefined function error.
I have tried using the Chrome debugger to step through the code where the error occurs but it just seems to highlight the jQuery source file for every step.
My question is this:
How do I go about tracking down the source of the issue when the trail is just a series of anonymous functions in the jQuery source file?
Is there something I am missing here or that I am not considering?
Thank you.
Edit:
As is it not clear, the method being called, jQuery.ContentSlider is in fact being included within the page within the file testimonials.js.
This is not just a "What's wrong with my code" question, but also an inquiry into how I handle situations such as this in the context of JavaScript & jQuery specifically.
A call stack of anonymous functions is confusing to me, and I have already attempted to take the obvious steps, such as verifying the plugin is included and that this inclusion takes place before attempting to utilize that plugin.
Sorry for the confusion.
Edit - Solution Found
It appears that although jQuery and the plugin were included prior to use, another copy of the same jQuery file was being injected by a Joomla! module. Since this was the exact same Google hosted jQuery file, it did NOT appear twice in the Resources tab in the Chrome Developer Tools. It appears that Chrome will parse jQuery twice, but doesn't show it as being included twice. So, the version with the plugin attached was being overwritten.
Thank you to those who answered. Thanks to A. Wolff for bringing that piece of information about the Resource tab to my attention.
You're loading the slider after you instantiate it.
Reverse the order of these two blocks:
<script type="text/javascript">
$(function() {
jQuery('#two').ContentSlider({
width : '440px',
height : '240px',
speed : 400,
easing : 'easeOutQuad',
textResize : true
});
});
</script>
<script src="/templates/sp/javascript/jquery.sudoSlider.min.js"></script>
Edit: To the heart of your well-formed question about debugging, generally, Undefined is not a function, especially when dealing with frameworks, is a symptom of trying to access a method before it exists, which is why your attempted function call returns undefined rather than a function.
It's almost always the result of loading a framework after trying to call it, or in an asynchronous context, of not waiting for the framework to load or do something important.
EDIT 2: The above answer is not correct, as A.Wolff points out: it's not that you must reverse the order of the two blocks, but that:
1) The second framework is probably not the one you want, or
2) You have called jQuery('#two').ContentSlider when you meant to call .sudoSlider, (or whatever is appropriate for that framework).
Our company site has a JavaScript problem that I'm desperately trying to solve, but really struggling with. My JS skills are good enough to build a site with things like jQuery, but I am not that proficient in debugging - so really appreciate any help.
Seemingly randomly, all JS components (e.g. a jQuery Datepicker) on the page stop working. When force-reloading the page with the error console open, these errors happen about 60% of the time - there doesn't seem to be any pattern to it. The only way to fix the site once this happens is by clearing the cache and reloading.
The Console outputs the following:
Uncaught TypeError: Object #<Object> has no method 'each'
Uncaught TypeError: Object #<Object> has no method 'not'
Uncaught TypeError: Object #<Object> has no method 'each'
However: that's just one example. Other times I will get completely different errors. E.g. a few minutes after submitting this question, I tried again, and got this:
Uncaught TypeError: Cannot call method 'apply' of undefined
Which again was thrown from jquery.min.js - pretty-printed, line 1453 (third line down):
if (g.call(k) === "[object Array]")
if (!u)
e.push.apply(e, k);
I set Chrome to break on all unhandled exceptions, and this was another exception it caught - on line 3 of the minified jQuery library. Shown below is the pretty-printed version:
try {
b.call(c.documentElement, "[test!='']:sizzle")
} catch (f) {
e = !0
}
The actual erroring line begins b.call[...]. This works out to line 1904 of jquery.min.js.
I am using the latest jQuery
This only started happening recently - after changing nothing!
The errors happen seemingly randomly
Usually (but sometimes), no errors are thrown from my scripts - e.g. script.js - usually they are thrown from a minified library. It varies each time.
This seems to happen in all browsers, but more often in Chrome than Firefox
Any ideas where to begin? Unfortunately this is an internal corporate website so providing access is tricky, as we deal with sensitive data throughout the site.
Thank you for your help!
Seems to me that your page is quite big and the browser tries to execute the js code before the DOM loads completely... probably because you're using in-line javascript code..
That could explain the random errors and the fact that you have errors when you force the reload.
I'd suggest you to put your JS code inside a dom ready event so the js code could be executed without problems..
Hope this helps :)