Random Quotes from Text File

read textfile by line

by Edsel Matt Morales

HTML

<button id="btn_modal">Give me a Quote</button>
<p id="kowts"></p>

CSS

#kowts {
    display:none;
    font-weight:bold
}

JavaScript

$('#btn_modal').click(function () {
    var num = 0;
    $.ajax({
        url: "https://dl.dropboxusercontent.com/u/75734877/taglines.txt",
        type: "GET",
        dataType: "text",
        beforeSend: function () {
            $('#kowts').show().html('<img src="http://www.feelol.com/Content/images/Loading.gif" />');
        },
        success: function (t) {
            var lines = t;
            var lineArr = lines.split('\n');
            num = Math.floor(Math.random() * lineArr.length);
            $('#kowts').show().text(lineArr[num]);
        },
        error: function(){
            alert('Error')
        }
    });
});