-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
31 lines (28 loc) · 936 Bytes
/
app.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
30
31
$(document).ready(function() {
$("#btn").click(function () {
$.ajax({
method: 'GET',
url: 'https://api.api-ninjas.com/v1/riddles',
headers: { 'X-Api-Key': '47TbcbBJKlCP92xRufCnOg==PTkLKDxbwTowUKbb'},
contentType: 'application/json',
success: function(result) {
const results = result[0];
setRiddle(results);
$( ".card" ).effect( "pulsate" );
},
error: function ajaxError(jqXHR) {
console.error('Error: ', jqXHR.responseText);
}
});
});
$("#show").click(function() {
$("#answer").show("fade");
});
});
function setRiddle(result) {
$('#title').html(result.title);
$('#question').html(result.question);
$('#answer').html(result.answer);
// Ocultar la respuesta al cargar un nuevo acertijo
$('#answer').hide();
}