How to initialize a JSON-RPC Service:
//You need the package of course
dojo.require("dojo.rpc.JsonService");
// Create a callback function to handle the results generated
// by a method A second optional parameter to your call back
// will allow the callback to use the submission Id of the
// json-rpc request
function contentCallBack(result) {
dojo.debug("in contentCallBack");
var handlerNode = document.getElementById("content");
handlerNode.innerHTML = result;
}
function contentErrBack(obj) {
dojo.debug(obj);
}
// Create a new object
var testClass = new dojo.rpc.JsonService("testClass.smd");
Push these buttons to execute code in the button.
Results will be returned below under "Returned Content"
This button will perform a simple echo
testClass.myecho("blah").addCallbacks(contentCallBack,contentErrBack);
This Button will simply call the function contentB()
testClass.contentB().addCallbacks(contentCallBack,contentErrBack);
This button will call add() to add two numbers together
testClass.add(5,6).addCallbacks(contentCallBack,contentErrBack);
This button will make a call that returns an RPC error (as opposed to a transport error)
testClass.triggerRpcError().addCallbacks(contentCallBack,contentErrBack);
This button will make a call that returns a transport error
erroringClass.content().addCallbacks(contentCallBack,contentErrBack);
None.