I'm a new web developer, and at the suggestion of Richard Bovell at JavaScript is Sexy, I've decided to test my skills by making a... well, test!
I did the basic HTML, and I've written a function to display any given question, and it works perfectly in JSFiddle.
However when I test it with PHPStorm (run it with my browser), it seems like the JavaScript/jQuery is not loading.
In fact, when I use Chrome's error console, jQuery.min says, "failed to load resources."
I'm using this code in my source:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
I've also tried using this source:
<script type='text/javascript' src='//code.jquery.com/jquery-1.10.1.js'></script>
but also not loading resource.
As a result, my entire JavaScript code is not working since it was jQuery based.
If I load the link into my web browser it works perfectly fine, so it doesn't seem like a network error.
Edit:
Here is my fiddle: http://jsfiddle.net/abustamam/3CY7g/
And the error reads:
Uncaught ReferenceError: $ is not defined script.js:2
(anonymous function) script.js:2
Failed to load resource file://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
Can anyone give me some pointers as to why jQuery isn't loading? Thanks!
Edit 2: Got the answer. http: is required! Thanks!
Try:
<script src = "http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
You were not entering a valid URL
When testing a file locally, i.e. not running it from an actual server, you need to specify the http:// or https://. So change:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
to
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
Related
I am using some JavaScript in my ASP.Net page like this:-
<script type="text/javascript" src="MyScript.js"></script>
<script type="text/javascript">
function validate_everything()
{
do_foo();
}
</script>
where MyScript.js exists in the same directory as the Default.aspx, and contains this (only):-
function do_foo()
{
var fred = 2;
return fred;
}
When I attempt to run this (using Internet Explorer) it produces the error:-
0x800a1391 - JavaScript runtime error: 'do_foo' is undefined
The real code (with actual useful work) handled in the same way was working fine yesterday, and fine earlier this morning. I modified it and this error started appearing; I reverted the changes and the error still appears. Before, using Chrome, the real version worked. Now, nothing happens (I assume the reason is the same).
I appreciate this question is a hardy perennial. My problem differs from those here and here in that I'm not using JScript, and this one in that I'm not adding the script from the code-behind.
I have used this approach in several other applications and the error does not occur there. Is that path going to pick up the file from the Default.aspx directory? Is there anything I need (in web.config or anywhere else) that I am lacking?
Edit on inspecting the page source (Chrome) the JavaScript in the .aspx file is listed as expected. The included file is shown thus:
<script type="text/javascript" src="MyScript.js"></script>
but no script is shown (ought there to be?)
I'm creating an small module for activeCollab composed by some webpages. I'm using PHP and Javascript/jQuery/AJAX. When I enter into the main page of the module I'm creating everything is working fine, but if later I try to go to other modules my web application is crashing. Is not showing any information. The only way for reviving it is refreshing the navigator.
If I check the error console of my navigator, I see that when I'm exiting from my custom webpage it says
`Uncaught Error: History.js Adapter has already been loaded...`
The header of my HTML file has this information:
<head>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
And this code is making my Javascript functions work properly.
What can be happening? I googled and I didn't found much information about this issue. Every help would be appreciated.
Finally I solved it, the problem was that my application is loading by default its own jQuery file and there was a conflict between this one and the ones I was trying to import. The solution was easy: I only had to delete the lines I wrote inside the "head" tag.
Thanks for your help!
This issue has been driving me crazy!
I am relatively new to web design. I started to learn coding on codecademy.com. Everything worked perfectly! html, css and JavaScript went smooth. However, this is not the case when I start coding with Sublime Text or DreamWeaver on my machine. Whenever I try to run my website, the scripts that I linked doesn't work. I copy-pasted the codes from a Codecadamy tutorial(html, css, JavaScript) into a completely new file in DreamWeaver(index.html, stylesheet.css and script.css), I did this to make sure my code isn't faulty. When I ran the code in the built-in Codecadamy browser, it works perfectly. But whenever I save the files with DreamWeaver or sublime text, the website seems to "ignore" the external .js file.. I tested the website on 4 different browsers(Chrome, IE, Firefox, Opera) but found no luck!
I have no idea what might be causing this problem..
I tried to copy my code into the built-in Codecadamy but it still didn't work
Heres my simple javascript code(just to test out whether its working on my machine):
$(document).ready(function() {
$('#openDialog').click(function() {
$('.container').css('display', 'none');
});
});
Here is my website, I hosted it in a public folder on my DropBox account;
https://dl.dropboxusercontent.com/u/33331786/xbox/index.html
Look at your browser's JavaScript console:
Uncaught ReferenceError: $ is not defined global.js:2
This is your source code:
<script type='text/javascript' src='global.js'></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
You are trying to use jQuery before you load it!
Are you using a local running server or are you using the file:// 'protocol' in your URL's? If you're not running a server then that 's the problem. Because of security constraints browsers do not run local JS files except when you explicitly enable the browser to do so.
See here for more info on how to do that: How to launch html using Chrome at "--allow-file-access-from-files" mode?
Do you ever reference the jQuery library? You could do it like this
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
Can you please take a look at this this link and let me know why the jQuery is not working here?
I am running the page on Cloud9 ide online editor and this the code I have before </body> tag
<script src="http://codeorigin.jquery.com/jquery-1.10.2.js" type="text/javascript"></script>
<script src="js/bootstrap.js"></script>
<script>
$(document).ready(function() {
alert("This is a Test Message");
});
</script>
</body>
Here is the list of error on consule:
Uncaught TypeError: undefined is not a function bootstrap.js:29
Uncaught ReferenceError: $ is not defined layout.html:48
Thanks
Try changing your
<script src="http://codeorigin.jquery.com/jquery-1.10.2.js" type="text/javascript"></script>
To
https:// instead of http://
If you look at the warning in your browser you'll see the reason why.
The problem is it refuses completely to load your jquery.js that cause $ undifined of course.
That's the warning I get :
[blocked] The page at https://c9.io/behseini/daycare/workspace/layout.html ran insecure content from http://codeorigin.jquery.com/jquery-1.10.2.js.
With that error I think you can follow that link :
Warning : The page index.html ran insecure content
Cause of your https, you have to load file on a https
Try with that url maybe : https://code.jquery.com/jquery-1.10.2.min.js
Hope that's gonna help you.
I was looking through some pages when I stumbled across this open source JavaScript date library: Datejs. Now I've been trying to use it but everytime I try any function like:
$(function() { Date.today().toLongDateString() } );
or even only
Date.today().toLongDateString()
withing tags, I get errors when the webpage loads, it tells me Date.today() is not a function but it appears as such in the documentation I've been at this for like almost 2 hours now xD it's driving me crazy and I know I just probably overlooked something...
I loaded the:
<script type="text/javascript" src="assets/js/dia_hora/date_es-MX.js"></script>
Are your script path and filename correct? You wrote:
<script type="text/javascript" src="assets/js/dia_hora/date_es-MX.js"></script>
But according to the "Getting Started" page of the project, it should be:
<script type="text/javascript" src="assets/js/dia_hora/date-es-MX.js"></script>
There are two hyphens in the original file: "date-es-MX.js", not an underscore. Or did you rename the file?
Check if the file correctly loads using Firefox Firebug (network tab) or FiddlerTool if you're using Internet Explorer.
Sounds like the script is not getting loaded. Put an alert('hello'); at the beginning of the script and see if you get that popup when the page loads.
Your path to the javascript file is incorrect.
OR
You have a syntax error in a Javascript file that is being loaded before this one. I believe the browser will stop trying to interpret the rest of the Javascript as soon as an error occurs.
Try having the JS Console open in Chrome or Firefox or Safari - you will get a much better idea of what the error is. JS Console has saved me hours or even days - I remember how I used to get frustrated about not being able to tell what happened when JS silently failed.
But with JS Console it's never a silent fail - you get some hint in the error message however small.