Tweet a random quote

Tweet a random quote
0

#1

Hi guys,
I am trying to tweet the random quote i get from an API and i don’t know what is wrong.
i declare a global variable var tweet_quote= $(’.quote ‘).text and use it in the the JQuery code to tweet it. When i try to console.log this varieble everything goes fine. When h try to open the window(
$(’#tweet’).on(‘click’, function(){

 window.open("https://twitter.com/intent/tweet="+tweet_quote);

});
) this way i cannot tweet it.
Here is my codepen project :http://codepen.io/Chrimors/pen/JWpKxQ?editors=1111

Thanks for the help, Christos


#2

At the start when you define tweet_quote there is no quote loaded yet. If you put the tweet_quote = $('.quote1').text(); inside the event handler it should work. Also, it should be "https://twitter.com/intent/tweet?text="+tweet_quote with the text parameter.

You will still have to format the string so it doesn’t break when there is a semi-colon (or other non-alphanumeric characters) inside.


#3

Great!
everything works fine . Thanks for the help!!!