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>
Related
My HTML is using a lot of js files (6 js files) including jquery js .
When i change the culture, some file does not load.
My html looks this way
<script src="~/Scripts/library/jquery.js"></script>
<script src="~/Scripts/Home/lory.min.js"></script>
<script src="~/Scripts/Home/modalEffects.js"></script>
<script src="~/Scripts/Home/classie.js"></script>
<script src="~/Scripts/library/jqueryval.js"></script>
<script src="~/Scripts/library/localstorage.js"></script>
I got the below error.
TypeError: $(...).magnificPopup is not a function $('.open-popup-link').magnificPopup({ registration.js (line 5) ReferenceError: lory is not defined // lory(multiSlides, { localhost:50978 (line 12, col 12
I am working on a web based application build in asp.net mvc4. and jquery as client side.
Its multi lingual site. English, french, Spanish and Portuguese.
All languages are working fine except Portuguese. When I select Portuguese some javascript file are not loading. and its working fine in other languages.
same code works for all other languages
thanks in advance.
TypeError: $(...).magnificPopup is not a function Means that some addon is blocking your script from working properly or if you are using adblock, it's probably blocking this script and interfering.
Had the same problem, My adblock seemed to cause it.
My javascript was working properly and then all of the sudden it wasn't. Chrome give me the Uncaught SyntaxError: Unexpected token ILLEGAL error on line 1 of my JS file called para2.js. I removed script from the file except for the following and I still get the error:
$( window ).ready(function() {
});
My jQuery file is included in the head of my document:
<script src="../shared/jquery.js" type="text/javascript"></script>
<script src="js/para2.js" type="text/javascript"></script>
When I look at my js file in Chrome developer tools on the Sources tab, it displays the script in Chinese:
兪敵祲搨捯浵湥⥴爮慥祤昨湵瑣潩⡮笩⥽
When I view the source of the js file, it looks fine. I have read similar posts that say copy and pasting from JSFiddle can include some hidden characters that may cause it, but I have started from scratch writing this file from a blank text file and copy and pasting nothing. It is strange that it was working and now it is not. Did my server get hacked or something? And help is appreciated.
You should use the charset attribute to indicate which charset you are using.
<script src="../shared/jquery.js" type="text/javascript" charset="UTF-8">
I had the same problem with jquery-1.5.1.min.js. Chrome kept evaluating it as Chinese (scripts worked fine in IE). I finally solved the problem by re-encoding the .js files using "convert to UTF-8" in Notepad++. Note, not UTF-8 without BOM, but UTF-8.
I am working with this demo: http://cssdeck.com/labs/setting-active-states-on-sticky-navigations-while-scrolling/
For some reason when I try to recreate it the Java part making the navigation work isn't coming through on my version here: http://cssdeck.com/labs/ydsxavxy
So far I saved out index.html, style.css, and flip.js and attempted to link the CSS and JS in the index.
How can I get my version working like the demo? How is a Java file included outside of CSSDeck? I am not too familiar with how CSSDeck takes the HTML, CSS, and Java and combines them into one page preview.
The version of jQuery you are loading is not correct.
The example that works uses 1.8, and you are loading 1.4:
<script class="cssdeck" src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
You can easily know this by looking at your browser console and seeing what errors it's throwing. In your case, the error is as follows:
TypeError: $(...).on is not a function
This usually means your jQuery library is not defined or not supported by the code you're using.
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.
I am getting the following error:
Microsoft JScript runtime error: 'Sys'
is undefined
While trying to execute:
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
//ERROR IN THIS LINE!!!
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(onUpdated());
function onUpdated() {
// get the update progress div
var pnlPopup = $get("div2");
// make it invisible
}
</script>
</head>
Ensure you have a Scriptmanager on the page and the script is below the scriptmanager. Maybe try to put your script tag into body and see what happens.
I don't know how you can fix that that its not in the body, but maybe there is a callback from Sys when its loaded
You don't need brackets to tell which function is neeeded:
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(onUpdated);
If that is your full code, then the problem is that the Microsoft AJAX libraries aren't being included. If it isn't your full code, then you need to post more as it's a little hard to get beyond the fact that the library isn't included. Somewhere in your file -- prior to the line you are having problems with you need to have a javascript include like:
<script type="text/javascript" src="/scripts/MicrosoftAjax.js" />
As well as probably a few others.
Note: I'm talking about the generated source. Showing more complete markup would probably also suffice.
I'm a bit late to the discussion here, but a simple solution is to create a "ASP.NET AJAX-Enabled Web Site" in Visual Studio and then merge the web.config from that site with your existing site.
In this way you get all the configuration you need without having to carefully read through a lot of docs. Speed is of the essence and all that :)
You can fix this issue by setting the EnableCDN property to "true".refer this link
I had the same issue , after all findings I found that the required script files ("MicrosoftAjax.js", "WebForms.js","jquery", "bootstrap" etc..) were not loaded properly which was causing me 3 errors "Sys' is undefined", "webform_docallback is undefined" and "webform_initcallback' is undefined", my actual problem was I had reference to these files which where not included in my propject, my bad I have not noticed it, I have tried all the possible solutions from the internet before I really found that my js files were not included and thats the reason its not loaded properly.
Hope this helps..