I came across this JavaScript library:
http://code.google.com/p/json-xml-rpc/I was able to port the sample script to it, it's pretty easy.
<html>
<head>
<title>javascript_client.html</title>
<script src="rpc.js"></script>
</head>
<body>
<h1>QueueMetrics JavaScript XML-RPC example </h1>
<hr>
<script>
var server = "/DAILY/xmlrpc.do";
function run() {
try {
var service = new rpc.ServiceProxy( server, {
asynchronous:false,
protocol: "XML-RPC",
methods: ["QM.stats"]
} );
res = service.QM.stats( "q1", "robot", "robot","", "",
"2005-10-10.10:23:12", "2009-10-10.10:23:10","",
[ "KoDO.DiscCauses", "CallDistrDO.AnsDistrPerDay" ]
);
document.getElementById("RESULT").innerHTML = plotBlocks(res);
} catch(e) {
alert("Error raised: " + e);
}
}
function plotBlocks( hmBlocks ) {
s = "";
for (var i in hmBlocks) {
s += "<h2>Block: " + i + "</h2>";
s += plotBlock( hmBlocks[i] );
}
return s;
}
function plotBlock( arBlock ) {
s = "";
for ( r =0; r < arBlock.length; r++ ) {
s += "<tr>";
for ( c = 0; c < arBlock[r].length; c++ ) {
s += "<td>" + arBlock[r][c] + "</td>";
}
s += "</tr>";
}
return "<table border=1>" + s + "</table>";
}
</script>
<input type="button" value="Click me!" onclick="run();" >
<div id="RESULT"></div>
</body>
</html>
This example requires the file
rpc.js that comes from the client side
of the JSON-XML-RPC JavaScript library (see here:
http://code.google.com/p/json-xml-rpc/ ).
Please note that the following file should be served on the same webserver as the QueueMetrics app it's going to access, or it will be denied access by the browser.
Please edit the file to set up access preferences.
We are going to include this example in QM as well.