Hi Webbr:
Try this code below. I have tried to comment in the example to explain what is going on. My hope is that the solution is straightforward.
You will need a Serial API key and place it into the script for this to work properly.
Good luck!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>ioBridge Serial Buffer Stream</title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("jquery", "1");
google.load("feeds", "1");
</script>
<script type="text/javascript">
function checkSerial(returnedStreamID) {
if (returnedStreamID) {}
else {returnedStreamID = "new";}
$.getJSON("http://www.iobridge.com/api/serial/buffer/key=FD_XXXXXXXXXXXXXXXXXXXX&streamID="+returnedStreamID+"&callback=?", function (data) {
// SerialData is the parsed variable that contains the serial string
var SerialData = data.serialObject.SerialData;
//Act on the serial string if it exists, otherwise go back and ask the API for the string
if (SerialData) {
// Update webpage (only purpose is a visual echo
document.getElementById('updateID').innerHTML = SerialData;
//Split Serial String into an array
var responseParts = new Array();
responseParts = SerialData.split("+");
//responseParts is an Array with the data
var firstPart = responseParts[0];
var secondPart = responseParts[1];
//etc.
//Perform actions
//Repeat
}
var streamID = data.serialObject.streamID;
checkSerial(streamID);
});
}
$(document).ready(function() {
checkSerial();
});
</script>
</head>
<body>
<div id="updateID">Listening...</div>
</body>
</html>