Hi I am having a series of issues with my JavaScript/jQuery code! And even though I browsed through a list of similar questions, I can't find any answers that fits my problem.
These are the issues logged to the Google Chrome developer console:
Thanks so much for your help!
Here's my JavaScript Code:
$(Document).ready(function() {
var quote;
function getNewQuote() {
$.ajax({
url: 'http://api.forismatic.com/api/1.0/',
jsonp: 'jsonp',
dataType: 'jsonp',
data: {
method: 'getQuote',
lang: 'en',
format: 'jsonp'
},
success: function(response) {
quote = response.quoteText;
$('#quote').text(response.quoteText);
if (response.quoteAuthor) {
$('#author').text('said by ' + response.quoteAuthor);
} else {
$('#author').text('- unkown');
}
}
});
}
});
view CodePen here: https://codepen.io/IDCoder/full/KZqNdr/
Try to replace
$(Document).ready(function() {...});
with
$(document).ready(function() {...});
I'm sorry! I should have also included my html
code in my question. I found that in my html
sheet's <head></head>
tags, I had this: <link rel="stylesheet" href="Random Quote Machine.css">
. This was a carry over from my text editor, wherein I needed that link for file communicae. I also tested this solution by inserting such a line of code into the html
sheet of another of my CodePen projects that includes JavaScript and jQuery, and then checked the Google Chrome developer and it gave the same error: Failed to load resource: the server responded with a status of 404 () . I am so happy!:D
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.