Question

I set up a simple jquery script on a test site on my Yahoo! Domains site. It's supposed to display a random string from a text file and dump it into a div with the appropriate class.

I can't seem to figure out what I've done wrong.

http://hennesseydesign.com/os/os.html

Here's the source:

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Oblique Strategies</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script>

<script type=“text/javascript”>
jQuery(document).ready(function($) {
    $.get('quotes.txt', function(data) {
        var quotes = data.split("\@");
        var idx = Math.floor(quotes.length * Math.random());
        $('.quotes').html(quotes[idx]);
    });
});
</script>
<style type="text/css">
.quotes {
        font-family: Georgia, "Times New Roman", Times, serif;
        font-size: 14px;
        font-style: italic;
        color: #000000;
        background-color:#eee;
        text-decoration: none;
        height:40px;
        text-align: right;
        overflow: hidden;
        width: 600px;
        display:table-cell;
        vertical-align:middle;
    }
</style>
</head>

<body>
<div class="quotes"></div>

</body>
</html>

The source text file is here: http://www.hennesseydesign.com/os/quotes.txt

I have a feeling that this is a server-side issue. I would appreciate any help!

Was it helpful?

Solution

You have used wrong quotes instead of " in the type attribute of the script element, so the contents of the script element is not processed

<script type="text/javascript">
jQuery(document).ready(function($) {
    $.get('quotes.txt', function(data) {
        var quotes = data.split("\@");
        var idx = Math.floor(quotes.length * Math.random());
        $('.quotes').html(quotes[idx]);
    });
});
</script>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top