Showing posts with label cwc 2011. Show all posts
Showing posts with label cwc 2011. Show all posts

Wednesday, March 30, 2011

Cricket score update - JSON

Hi

I probably should have got this script done long back. If you have a website or a blog where you want to integrate the score update for CWC 2011, then you just need to use the code given below. In this I am using an JSON API of json-cricket.appspot.com for fetching the details. All you have to is parse the JSON returned. The output will be as follows:


This API has not been tested thoroughly, but it surely returns. Here is the code:

For simple HTML

<html>

<head>
<title>Cricket Score Update</title>
</head>
<body>
<div id="score_board"></div>
<script type="text/javascript">
o={s:function(data){document.getElementById("score_board").innerHTML=data.match + "<br />" + data.score + "<br />" + data.summary;}};