<html>
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>
<body>
  <div class="container">
    <h1>GitHub API Status</h1>
    <p id="status"></p>
    <p id="data"></p>
    <p id="error"></p>
  </div>

</body>
</html>
    body {
      display: flex;
      align-items: center;
      justify-content: center;
      height: 100vh;
      font-family: Arial, sans-serif;
    }

    .container {
      background-color: #e0e5ec;
      padding: 40px;
      border-radius: 10px;
      box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.2);
      text-align: center;
      transition: transform 0.3s ease;
    }

    .container:hover {
      transform: translateY(-5px);
      box-shadow: 0px 5px 20px rgba(0, 0, 0, 0.3);
    }

    h1 {
      font-size: 24px;
      margin-bottom: 20px;
      color: #fff;
    }

    p {
      margin-bottom: 10px;
    }

    #status {
      font-weight: bold;
      font-size: 18px;
    }

    #error {
      color: #c0392b;
    }

    .container.success {
      background-color: #27ae60;
      color: #fff;
    }

    .container.error {
      background-color: #c0392b;
      color: #fff;
    }
$(document).ready(function(){
  var retryCount = 0;
  var maxRetries = 3;

  function fetchData() {
    $.ajax({
      url: "https://api.github.com/",
      type: "GET",
      success: function(){
        $(".container").addClass("success");
        $("#status").html("The GitHub API is working");
      },
      error: function(){
        if (retryCount < maxRetries) {
          retryCount++;
          $("#status").html("Connection error. Retrying... (" + retryCount + "/" + maxRetries + ")");
          setTimeout(fetchData, 3000); // Retry after 3 seconds
        } else {
          $(".container").addClass("error");
          $("#status").html("The GitHub API is not working");
        }
      }
    });
  }

  fetchData();
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.