Random Quote Generator Help

Random Quote Generator Help
0

#1

Hi! I have two problems with my Random Quote generetor. It works, but it’s very slow for some reason - I have to click a button and wait, and only after 5 or more seconds quote changes. Second thing is, I can’t make it display a random quote when the page is just loaded. I tried to write function GetQuote separately and then invoke it inside $(document).ready like this:

 function getQuote(quote, author){
    $.getJSON("https://crossorigin.me/http://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=?", function (json){
    quote = json.quoteText;
    author = json.quoteAuthor;
    $(".tweet-button").attr("href", "https://twitter.com/intent/tweet?text=" + encodeURIComponent('"' + quote + '" ' + author));
    $(".quoteText").html("<p>"+ quote+"<p>");
    $(".quoteAuthor").html( "<em>" + "- "+ author + "<em>");
        if (author === "")
        {
             $(".quoteAuthor").html( "- Unknown");
        }
        });
    };
    $(document).ready(function(){
    getQuote(quote, author);
    $("#getQuote").on("click", getQuote(quote, author));
    $(".tweet-button").on("click", function(){
    openURL("https://twitter.com/intent/tweet?text=" + encodeURIComponent('"' + quote + '" ' + author));
    });
                 
    });

but it didn’t work, I couldn’t even change quote on a click. My project in its current state is there: http://codepen.io/enk/pen/EgABOR, please give me any feedback you can. Thanks in advance!


#2

Get rid of the:

https://crossorigin.me/

part in

$.getJSON("https://crossorigin.me/http://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=?", function (json){

will speed things up


#3

oh, it worked, thanks a lot!