Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
  <table>
    <thead>
      <tr>
        <td>Team 1</td>
        <td>Team 2</td>
        <td>Winner</td>
      </tr>
    </thead>
    <tbody id="tableBody"></tbody>
  </table>
</body>
</html>
 
var $tableBody = $('#tableBody');
function createRow (dm) {
  var team_1 = dm['team-1'],
      team_2 = dm['team-2'],
      winner = (
        dm['toss_winner_team']
        ? dm['toss_winner_team']
        : 'N/A'
      )
  return (
    '<tr>' +
        '<td>' + team_1 + '</td>' +
        '<td>' + team_2 + '</td>' +
        '<td>' + winner  + '</td>' +
    '</tr>'
  )
}
$.get("https://cricapi.com/api/matches?apikey=DSyFXyxkkyMk1t1L0FNiInn3Pu92", function(matchdata) {
  console.log(matchdata.matches);
  var rows = matchdata.matches.map(createRow).join('');
  
  $tableBody.html(rows);
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
angelsalazarpro
0viewers