I wrote a script that polls Twitter via Prototype's AJAX methods, grabs JSON results, evals them and then updates a div with the formatted tweets. Everything worked fine in testing (Safari 4.0.3 on a OS 10.6.1 machine) until I loaded the script onto a server and it failed. The script had all client side items and referred to the same Prototype.js file, so I can't figure out why it was working locally but not remotely.
I stripped the script down to its bare essence -- just returning the latest tweet on my timeline into an alert box -- and works / breaks in the same way described above, and also in Firefox. I'm sure I'm making a boneheaded mistake, but can't find the error of my ways.
Here's the entirety of my page. Works locally, not on server or in Firefox:
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.2/prototype.js"></script>
<script type="text/javascript" charset="utf-8">
document.observe("dom:loaded", function(){
var tweetAddress = "http://twitter.com/status/user_timeline/hellbox.json?count=1";
new Ajax.Request( tweetAddress, {
method: 'get',
onSuccess: function (transport) {
var tweets = transport.responseText.evalJSON();
alert(tweets[0].text);
}
});
});
</script>
</head>
<body>
</body>
</html>