forked from wdi-sg/random-quote-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
35 lines (35 loc) · 1.22 KB
/
script.js
File metadata and controls
35 lines (35 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
$(document).ready(function() {
$quotes = $('.quotes')
$quoteButton = $('.quoteButton')
$tweetButton = $('a')
$container = $('#container')
// $twitDesc = $('meta[name="twitter:description"]')
$quoteButton.on('click', function() {
$.ajax({
url: 'https://andruxnet-random-famous-quotes.p.mashape.com/?cat=<required>', // The URL to the API. You can get this in the API page of the API you intend to consume
method: 'GET', // The HTTP Method, can be GET POST PUT DELETE etc
data: {}, // Additional parameters here
dataType: 'json',
success: function(data) {
$quotes.html(data.quote)
$container.html('')
twttr.widgets.createShareButton(
'/',
document.getElementById('container'), {
size: 'large',
text: data.quote
}
)
// $tweetButton.data('text', data.quote)
// .replace(/\s/g, '%20')
// $twitDesc.attr('content', data.quote)
},
// error: function(err) {
// alert(err);
// },
beforeSend: function(xhr) {
xhr.setRequestHeader('X-Mashape-Authorization', 'Gy5qvGErt9mshInarkyuo6B7ghA2p1fd5P1jsnLTfwF5pgUCMj') // Enter here your Mashape key
}
})
})
})