btcticker.appspot.com
Interesting...it pulls the information I'd want to use, but it only appears to offer to return the result as text rendered into a PNG.
I've been trying to wrap my head around handling JSON data inside JavaScript. You'd think this would be easy, but most browsers throw up a roadblock to keep a page from accessing JSON data from other sources. While this fends off a potential source of XSS attacks, it makes working with data a bit of a pain. Consider this, based on
this demo:
<html>
<head>
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="http://saltybeagle.com/cors/cors.js"></script>
</head>
<body onload="javascript:OnLoad();">
<div><span id="foo"></span></div>
<script type="text/javascript">
function OnLoad()
{
getCORS("http://ucommbieber.unl.edu/CORS/cors.php", null, function(data) { document.getElementById("foo").innerHTML=data; });
}
</script>
</body>
</html>
http://ucommbieber.unl.edu/CORS/cors.php returns a plaintext message when you send it a GET request. getCORS() is supposed to use
cross-origin resource sharing (CORS) to enable fetching data from remote sources. When you point it at any of the blockchain.info API URLs (even plaintext ones like
http://blockchain.info/q/hashrate), though, it fails to pull anything through. I suspect there's something not implemented server-side. JSONP fails pretty miserably, too. Is there any method to access JSON data on a remote site from JavaScript in a browser that doesn't rely on you running your own webserver or proxy and that doesn't rely on anything special being set up on the remote server? Basically, it should be possible to write some HTML and JavaScript into a file and have a browser run it. I'll be damned if I can figure it out, though. I've done plenty of JSON manipulation with PHP, so it's not like I'm completely unfamiliar with it.