Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Chain jQuery Notifications Websockets Example
<!doctype html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
</head>
<body>
<ul id="thashlist"></ul>
</body>
<script type="text/javascript">
$(function() {
var conn = new WebSocket("wss://ws.chain.com/v2/notifications");
conn.onopen = function (ev) {
var req = {type: "new-transaction", block_chain: "bitcoin"};
conn.send(JSON.stringify(req));
};
conn.onmessage = function (ev) {
var x = JSON.parse(ev.data);
var thash = x['payload']['transaction']['hash'];
$('#thashlist').append('<li>' + thash + '</li>');
};
});
</script>
</html>
@adv0r
Copy link

adv0r commented Jan 22, 2016

is this outdated now? I get a net::ERR_NAME_NOT_RESOLVED . Do you know how to achieve the same result?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment