I have a live site and I open it on Internet explorer and right click on page and click on view source and copy all code from it and paste it on vs2010->Newwebsite and when i run my site on vs2010 an error occur.
Microsoft JScript runtime error: '$' is undefined
I don't understand what I do. Kindly suggest me.
waiting for reply.
Thanks
You'd fix that by including jQuery!
Add the following to your page
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
However, it sounds like just an error in Visual Studio, and if it works when viewing the page in a browser, it shouldn't be an issue.
First verify that jQuery is in fact being loaded.
if (window.jQuery) {
alert("jQuery is loaded!");
}
If that works, then you are most likely using something like jQuery.noconflict() to remove the alias $ for jQuery.
Related
So first some background. This code is to be used as a bookmarklet and I've done testing with it as a bookmarklet and as code pasted into the javascript console in Chrome. Either way I'm getting the same error, Uncaught ReferenceError: $ is not defined.
Now before anyone tells me that I don't have jQuery embedded anywhere in my code, this is to be used on a website that has jQuery, and when I paste the exact same code in just not inside of a setInterval() it works fine, so here's my very simple code.
javascript:window.setInterval(function() { $("#fbutton").click() }, 5000);
On Chrome in the developer tools, $ is a shortcut for document.querySelector. So that is why it is valid in the console.
What you are running is actually
document.querySelector("#fbutton").click();
https://developers.google.com/web/tools/chrome-devtools/console/command-line-reference#selector
I've created a new Foundation 5 project through bash, with foundation new my-project. When I open the index.html file in Chrome an Uncaught TypeError: a.indexOf is not a function error is shown in the console, originating in jquery.min.js:4.
I created the project following the steps on the foundation site, but I can't seem to get rid of this error. Foundation and jQuery look like they are included and linked up correctly in the index.html file, and the linked app.js file is including $(document).foundation();
Does anyone know what is causing this error? and what a solution might be?
This error might be caused by the jQuery event-aliases like .load(), .unload() or .error() that all are deprecated since jQuery 1.8. Lookup for these aliases in your code and replace them with the .on() method instead. For example, replace the following deprecated excerpt:
$(window).load(function(){...});
with the following:
$(window).on('load', function(){ ...});
Please add below jQuery Migrate Plugin
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://code.jquery.com/jquery-migrate-1.4.1.min.js"></script>
This error is often caused by incompatible jQuery versions. I encountered the same error with a foundation 6 repository. My repository was using jQuery 3, but foundation requires an earlier version. I then changed it and it worked.
If you look at the version of jQuery required by the foundation 5 dependencies it states "jquery": "~2.1.0".
Can you confirm that you are loading the correct version of jQuery?
I hope this helps.
I faced this issue too. I was using jquery.poptrox.min.js for image popping and zooming and I received an error which said:
“Uncaught TypeError: a.indexOf is not a function” error.
This is because indexOf was not supported in 3.3.1/jquery.min.js so a simple fix to this is to change it to an old version 2.1.0/jquery.min.js.
This fixed it for me.
One of the possible reasons is when you load jQuery TWICE ,like:
<script src='..../jquery.js'></script>
....
....
....
....
....
<script src='......./jquery.js'></script>
So, check your source code and remove duplicate jQuery load.
I'm using jQuery 3.3.1 and I received the same error, in my case, the URL was an Object vs a string.
What happened was, that I took URL = window.location - which returned an object. Once I've changed it into window.location.href - it worked w/o the e.indexOf error.
It's seems to be funny but no one take consideration of the following.
Discover if you are having a library that requires an old version of jQuery. If you can't discover the version, You can do it commenting and uncommenting every script line until you find it.
Open the library and find the author.
Search in google for an update of the library. 90% you will find it.
Update the reference of your obsolete library that requires and old version of jQuery.
IN ANY CASE NEVER DOWNGRADE YOUR JQUERY VERSION
I solved this by installing the correct version of Jquery that my project required using npm
I'm learning some jquery using codeacademy and while everything works great within the codeacademy editor, it doesn't work when I upload to a server.
Here is the html in question:
www.arbabmazumdar.com/kudos.html
and here is the js:
www.arbabmazumdar.com/Web_Files/test.js
what am i doing wrong?
1)
<script type="text/javascript" src="../Web_Files/test.js"></script>
You don't actually need the .. part as resources are loaded relatively (i.e. from the same "directory") to the HTML file. Web_Files/test.js would be enough.
2) Your file loads just fine, but you didn't include jQuery, so it fails:
Uncaught ReferenceError: jQuery is not defined test.js:88
Uncaught ReferenceError: $ is not defined kudos.html:19
When something doesn't work it's good to check for errors in the JavaScript console(using Firebug, Chrome Dev tools or IEs Developer Toolbar, etc.)
You have not yet included jQuery !
Include this in <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
in <head></head>
I am implementing a JQuery Lightbox on a website I'm working on. The same set of codes work very well in localhost, but when I transfer the codes to my server, I get this error concerning the lightbox. Uncaught TypeError: Object function Object() { [native code] } has no method 'extend' . I have no idea what error this signifies.
Also I only have jQuery lib on the page.
here is the page I'm working on mypage
Please help me.
Update
I added <script>jQuery.noConflict();});</script> within <head></head> of html..in between jquery lib and lightbox script link. But still not working.
Thanks
Working well, you may try to reupload lightbox.css to fix alignment issue.
A lot of times that error happens when a dependent script is missing. It can also happen if you are using multiple libraries besides jQuery.
When I started working with OpenLayers, console.log stopped working and I kept getting this error in the chrome terminal.
GET http://127.0.0.1/my/private/dir/undefined/firebug.html 404 (Not Found)
At first I didn't realize it was OL so I uninstalled the firebug lite plugin. Then I checked the OL source and found where it's trying to inject firebug.
y=document.createElement("iframe");y.setAttribute("src",o+"/firebug.html");
Is there a way to prevent OL from doing that other than modifying the source. Also, it's overwriting window.console
I met the same problem.
I fixed it for the moment by adding:
<script type="text/javascript">
console.firebug=true;//fix the openlayer problem
</script>
before loading the openlayer script.
the reason:
console.log used to work in the previous version of Openlayer ,but not for now, so I checked the source code found there is:
if (!window.console || !console.firebug) { ...
which means I guess if there is no FIREBUG console, the console will be cleaned up and overwritten.
I think it should be a bug , so I just didn't get further into this, and try to fix it as soon as possible, waiting for the bug fixed by the Openlayer guy.
hope it work for you, if not,please let me know.
are you including an external file like firebug.js or something like that in the code.. I dont think it should do anything by defualt and it must hv sm code that checks if a certain objects exists in the scope or something.
Hope you are not using some example code and that is why you are facing this issue.
also make sure that you have the irght version of OL and not a patched version or a beta version.
please update us.
A link that I found: http://osgeo-org.1803224.n2.nabble.com/Firebug-Error-Invalid-Object-Initializer-td2866563.html
btw this is openlayers stand on it:
add OpenLayers.Console namespace and a number of methods that allow for logging of error messages - when firebug.js is included in a page, the application runs in "debug" mode - the Firebug extension or Firebug Lite handles OpenLayers.Console calls depending on availability
I ended up just commenting out the line that adds the iframe. And I load a script before OpenLayers which creates a backup of window.console.
window.console2 = {};
for(key in window.console)
window.console2[key] = window.console[key];