Тема: Using Wayback JSON API

Hi,

I have another request for help on a JSON API. I'm trying to build a program that will make a request to the Wayback JSON API and use the information to show to the user. As there is too many JSON formats i couldn't make it work using the examples i already have.

The request URL is:

[code]http://archive.org/wayback/available?url=example.com[/code]

And the result is:
[code=JSON]{
    "archived_snapshots": {
        "closest": {
            "available": true,
            "url": "http://web.archive.org/web/20130919044612/http://example.com/",
            "timestamp": "20130919044612",
            "status": "200"
        }
    }
}[/code]

The last code that i'm using is (Not working):
[code=JavaScript]<script>
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            var myObj = JSON.parse(this.responseText);

            for (x in myObj.archived_snapshots.closest) {

                document.write(''+ myObj.archived_snapshots.closest[x].available +'\n');
            }
        }
    };
    xmlhttp.open("GET", "http://archive.org/wayback/available?url=example.com", true);
    xmlhttp.send();
</script>[/code]

I'm only using this code because it has worked previously on other projects but i don't think that is correct at all. As the previous projects worked in a loop.

Thanks