Does someone know how I can fix this code? It gives me error in line 5, in $.getJSON, it say "uncaught reference error: $ is not defined"
<link rel="stylesheet" href="style.css">
<script>
var url = "https://api.minetools.eu/ping/mc.hypixel.net/25565";
$.getJSON(url, function(r) {
//data is the JSON string
if(r.error){
$('#resto').html('Server Offline');
return false;
}
var pl = '';
if(r.players.sample.length > 0 ){ pl = '<br>OP: '+r.players.sample[0].name; }
$('#resto').html(r.description.replace(/§(.+?)/gi, '')+'<br><b>Players Online:</b> '+r.players.online+pl);
$('#favicon').attr('src', r.favicon);
});
var rest = resto
</script>
<div class="card"> <div class="icon"><img src="https://www.joomla.it/images/immagini/sampledata/Joomla-flat-logo-en.png" id="favicon"></div><div class="header">
<div class="image"> <img src="https://pbs.twimg.com/media/C2bx8KGWQAEORsE.jpg" alt="" /> </div>
<h2>mc.hypixel.net</h2>
</div>
<div id="rest">Loading ...</div>
</div>
Add jquery library before your script
<script src="http://code.jquery.com/jquery-3.5.1.min.js"></script>