jQuery is not Runnig - javascript

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.

Related

HTML won't recognize my the javascript file I am asking it to run, SyntaxError: Unexpected token '<' (anonymous function)script.js:1

I have a very simple HTML file that looks like this
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>Words</p>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type ='text/javascript' src ="js/script.js"></script>
</body>
</html>
And the file script.js is in a directory called js and that directory is located in the same directory as the HTML file. script.js looks like this:
function myFunction(){
alert("Hello World");
}
The alert won't show up, and the console just says
SyntaxError: Unexpected token '<'
(anonymous function)script.js:1
From debugging, this error seems to indicate that it can't find the file script.js though for the life of me I can't figure out why.
Most likely there is something wrong resolving tour javascript file and the server returns HTML instead (most likely a 404 not found page).
You can diagnose this by checking the console of your browser (hit F12). Check the network tab and see if it loads okay.
After that, make sure the file exists, it is available directly from your browser, etc.

ReferenceError:gapi is not defined

I am seeing ReferenceError:gapi is not defined error when accessing the Google+ APIs from my HTML code.
My code is very simple, but not sure what is wrong with it.
Any inputs would be highly appreciated.
Please see my code below:
<html>
<head>
<title> Some title here </title>
<script src="https://apis.google.com/js/platform.js"></script>
<script>
function handleClientLoad(){
gapi.client.setApiKey('MY API KEY HERE')};
</script>
<script src="https://apis.google.com/js/client.js? onload=handleClientLoad"></script>
</head>
<body>
</body>
</html>
Error is
Execution failed: ReferenceError: "gapi" is not defined
I'm not sure if this is the answer, but I notice that there is a space between "client.js?" and "onload=". This might not be in your original code, but it does cause the client.js request to return different code.
I was able to fix the issue. I should have added more details to the question but didnt thought that the issue could be somewhere else. Sorry for the same.
When we create a Web App project in Google Drive, the javascript code which runs on the server and the code which runs on the client(a browser) should be specified in different files. These files are Code.gs and JavaScript.html respectively. "gapi" is a client code (defined in client.js) and I was referencing to it in the server file. Since server code is running in the Google servers, it has no clue about our client.js and platform.js libraries. Hence the error. When I moved the error causing code to JavaScript.html, it worked fine.
Thanks.,

Uncaught ReferenceError for SoundCloud SDK

I'm trying to use the SoundCloud sdk for javascript and I keep getting a "Uncaught ReferenceError: SC is not defined" error.
I followed everything on the reference page https://developers.soundcloud.com/docs/api/sdks right here.
I looked at all the other questions similar to mine on here and people suggested splitting the script tags so one of them has the src attribute and the other one has the actual script.
But I already have done this and it isn't solving my problem.
Here is my code:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript" src="http://connect.soundcloud.com/sdk-2.0.0.js"></script>
<script type="text/javascript">
$(document).ready(function() {
SC.initialize({
client_id: "3f7407c6252e6932c8ef6ea85c55e9c7"
});
});
</script>
Thank you in advance.
This code seems to be working correctly, check this fiddle: http://jsfiddle.net/4k31v0ec/.
I've added
console.log(SC);
to see if the API object is initialised. So maybe you have error in other part of your page code?
UPD
try using https url for library url:
https://connect.soundcloud.com/sdk-2.0.0.js

Error in console: uncaught error history.js adapter has already been loaded

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!

Website not loading jQuery

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>

Categories

Resources