2010-11-22

Code to handle availability problems

We have devised a solution to handle the event of Avail SaaS not being available. 
Before the Avail script tag add a row that declares a empty Emark object:
<script type="text/javascript">var Emark;</script>
Add an if-then statement before the Avail-specific code that checks if the object is available: 
if(Emark){
//Avail Code
}





Full page sample:
<html>
<head>
<script type="text/javascript">var Emark;</script>
<script type="text/javascript" id="thescript" charset="UTF-8" src="http://service.avail.net/2009-02-13/dynamic/XXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/emark.js"></script>
<script type="text/javascript">
function populatePredictions(){
if(Emark){
var emark = new Emark(false);
var recs = emark.getProductsPredictions(['0208931'], 'GETRELATED_DEFAULT');
emark.commit(function() { 
document.getElementById("prodRecsDisplay").innerHTML += "Recs: " + recs; 
});
}
}
</script>
</head>

<body onload="populatePredictions();">
<h3>Sample Page</h3>

<b>Recommendations</b>
<div id="prodRecsDisplay"></div>

</body>
</html>

No comments: