Started to find quotes, instead found jokes.
A Pen by Ornataweaver on CodePen.
| <body class="text-center"> | |
| <br> | |
| <h2>Jokes that I connected via Ajax:</h2> | |
| <p class="message"> | |
| The joke will go here | |
| </p> | |
| <button id="getQuote"> | |
| Get Message | |
| </button> | |
| </body> |
Started to find quotes, instead found jokes.
A Pen by Ornataweaver on CodePen.
| $(document).ready(function() { | |
| // twttr.widgets.load(); | |
| // function getQuote(){} | |
| $("#getQuote").on("click", function(){ | |
| var html = ""; | |
| $.getJSON("https://api.icndb.com/jokes/random.json", function(obj) { | |
| html += "<div>"; | |
| html += obj["value"]["joke"] + "<br>" + "<strong>" + "from 'https://api.icndb.com/jokes/random/' " + "JokeID=" + obj["value"]["id"] + " " + "</strong>" + "<br>" ; | |
| html += "</div>"; | |
| $(".message").html(html); | |
| }); | |
| }); | |
| }); |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script> |
| body { | |
| background: #aa0; | |
| /* text-align: center; */ | |
| font-family: monospace; | |
| color: #000; | |
| font-size: 20px; | |
| } | |
| button { | |
| border-radius: 5px; | |
| } |
| <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" /> |