-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
31 lines (27 loc) · 955 Bytes
/
script.js
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
$(document).ready(function(){
$("#new").click(function() {
var imgUrl;
var imgId;
$.ajax ({
url: "https://api.giphy.com/v1/gifs/random?api_key=GML25hSunINGi6eDyXGGInxZuT3BiAYC&rating=pg&tag=funny",
type: "GET",
dataType: "json",
success: function(response) {
imgUrl = response.data.embed_url;
imgId = response.data.id;
console.log(response);
$("#giphy-embed").attr("src", imgUrl);
// $("#giphy-embed").attr("src", "https://media.giphy.com/media/"+imgId+"/giphy.gif");
return false;
},
error: function(e) {
console.log("uh oh");
}
});
});
});
$(document).ready(function(){
$("#giphy-ok").click(function() {
$("#giphy-embed").attr("src", "https://giphy.com/embed/"+$("#giphy-id").val());
});
});